This action replaces tokens in files with variable values.
The first version was intended for use mainly in internal projects. But there are plans to expand the functionality.
Please refer to the release page for the latest release notes.
- uses: alexander-trishin/replace-token@v1
with:
# A multiline list of files to replace tokens in.
#
# Each line supports glob pattern.
# [Learn more about glob patterns](https://github.com/actions/toolkit/tree/main/packages/glob#patterns)
#
# Required.
target:
# The encoding to read and write all files.
#
# Accepted values:
# - auto: detect encoding using chardet
# - ascii
# - utf-8
# - utf-16le
#
# Optional. Default: "auto"
encoding:
# Indicates whether to follow symbolic links while searching for target file(s).
#
# Optional. Default: true
follow-symbolic-links:
# The token prefix for using custom token pattern.
#
# Optional: Default: "${{"
token-prefix:
# The token suffix for using custom token pattern.
#
# Optional. Default: "}}"
token-suffix:
# A YAML formatted multiline string containing variable values (keys are case-insensitive).
#
# May override values from `variables-json` and `variables-secret-json` if keys match.
#
# Example: >
# - VARIABLE0: VALUE0
# - VARIABLE1: ${{ vars.VALUE1 }}
#
# Optional. Default: ""
variables:
# A JSON formatted multiline string containing additional variable values (keys are case-insensitive).
#
# Values may be overwritten by `variables-secret-json` and `variables' if keys match.
#
# Optional. Default: ""
variables-json:
# A JSON formatted multiline string containing additional variable values (keys are case-insensitive, all values are masked).
#
# Values may override `variables-json` and be overwritten by `variables' if keys match.
#
# Optional. Default: ""
variables-secret-json:
vars
contextsecrets
context- uses: alexander-trishin/replace-token@v1
with:
target: ./templates/example.txt
variables: >
- TOKEN: value
- uses: alexander-trishin/replace-token@v1
with:
target: ./templates/example.txt
encoding: utf-8
variables: >
- TOKEN: value
- uses: alexander-trishin/replace-token@v1
with:
target: |
./templates/example-0.txt
./templates/example-1.txt
variables: >
- TOKEN: value
- uses: alexander-trishin/replace-token@v1
with:
target: ./templates/*
variables: >
- TOKEN: value
- uses: alexander-trishin/replace-token@v1
with:
target: ./templates/examples/*.txt
follow-symbolic-links: false
variables: >
- TOKEN: value
- uses: alexander-trishin/replace-token@v1
with:
target: ./example.txt
token-prefix: "#"
token-suffix: "%"
variables: >
- TOKEN: value
vars
context- uses: alexander-trishin/replace-token@v1
with:
target: ./example.txt
variables-json: ${{ toJson(vars) }}
secrets
context- uses: alexander-trishin/replace-token@v1
with:
target: ./example.txt
variables-secret-json: ${{ toJson(secrets) }}
The scripts and documentation in this project are released under the MIT License