Skip to content

Replace Tokens (abhinavminhas)

Actions
Replaces tokens in the text or code files with replacement values during the execution of the CI/CD process
v1.2
Latest
Star (0)

Tags

 (1)

replace-tokens

Replace tokens (GitHub action) replaces tokens in the text or code files with replacement values during the execution of the CI/CD process.

Replace-Tokens codecov maintainer License: MIT GitHub Release

Inputs

  • files (Required) - File names (path included), comma-separated for multiple files.
    • Example: file1, file2
  • replacements (Required) - Token (to be replaced) & value comma-separated pairs (TOKEN=value).
    • Example: key1=value1, key2=value2
    • Note:
      • key & value pairs ignore leading & trailing whitespaces. Enclose within [] for such expressions.
      • key (token) cannot have any = but value can. Use a different key (token) in such case.
      • key, value or pairs can be CI/CD variables / secrets.
  • delimiter (Optional) - Defines separator/delimiter to be used, default value is comma (,).
    • Example: | or ; or : or - etc.
    • Note: Ignores whitespaces.

Usage

  • Example 1: Replace a token in a file.

    - name: Replace Tokens
      uses: abhinavminhas/replace-tokens@main
      with:
        files: file
        replacements: key=value
    
  • Example 2: Replace multiple tokens in a file.

    - name: Replace Tokens
      uses: abhinavminhas/replace-tokens@main
      with:
        files: file
        replacements: key1=value1, key2=value2
    
  • Example 3: Replace a token in multiple files.

    - name: Replace Tokens
      uses: abhinavminhas/replace-tokens@main
      with:
        files: file1, file2
        replacements: key=value
    
  • Example 4: Replace multiple tokens in multiple files.

    - name: Replace Tokens
      uses: abhinavminhas/replace-tokens@main
      with:
        files: file1, file2
        replacements: key1=value1, key2=value2
    
  • Example 5: Use a different separator than comma (,).

    - name: Replace Tokens
      uses: abhinavminhas/replace-tokens@main
      with:
        files: file1 | file2
        replacements: key1=value1 | key2=value2
        delimiter: '|'
    
    • Note: The delimiter is enclosed within single quotation marks in the above example since yml interprets | as "Literal Block Scalar", also required for other reserved keywords.

Note: Implementation for above examples can be checked here.

Replace Tokens (abhinavminhas) is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Replaces tokens in the text or code files with replacement values during the execution of the CI/CD process
v1.2
Latest

Tags

 (1)

Replace Tokens (abhinavminhas) is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.