qetza/ReplaceTokens

Replace tokens in text files with variables and/or secrets.

View on GitHub

Trust Signals

Scorecard Score
not yet scored
Maintenance Recency
Stale
License
None
namedescriptionrequireddefault
sourcesA multiline list of files to replace tokens in. Each line supports: - multiple globbing patterns separated by a semi-colon ';' using fast-glob syntax (you must always use forward slash '/' as a directory separator) - outputing the result in another file adding the output path after an arrow '=>' (if the output path is a relative path, it will be relative to the input file) - wildcard replacement in the output file name using an asterix '*' in the input and output file names Example: '**/*.json; !local/ => out/*.json' will match all files ending with '.json' in all directories and sub directories except in `local` directory and the output will be in a sub directory `out` relative to the input file keeping the file name. yes
variablesA JSON serialized object containing the variables values. The object can be: - an object: properties will be parsed as key/value pairs - a string starting with '@': value is parsed as multiple glob patterns separated by a semi-colon ';' using fast-glob syntax to JSON or YAML files - a string starting with '$': value is parsed as an environment variable name containing JSON encoded key/value pairs - an array: each item must be an object or a string and will be parsed as specified previously Multiple entries are merge into a single list of key/value pairs and all JSON supports comments. Example: '[${ toJSON(vars) }}, ${ toJSON(secrets) }}]' will pass all defined variables and secrets. yes
add-bomAdd BOM when writing files.false
case-insensitive-pathsEnable case-insensitive file path matching in glob patterns (sources and variables).false
chars-to-escapeThe characters to escape when using 'custom' escape.
encodingEncoding to read and write all files. Accepted values: - auto: detect encoding using js-chardet - any value supported by iconv-lite auto
escapeCharacter escape type to apply on each value. Accepted values: - auto: automatically apply JSON or XML escape based on file extension - off: don't escape values - json: JSON escape - xml: XML escape - custom: apply custom escape using escape-char and chars-to-escape auto
escape-charThe escape character to use when using custom escape.
if-no-files-foundThe behavior if no files are found: ignore, warn, error.ignore
include-dot-pathsInclude directories and files starting with a dot '.' in glob matching results for sources and additionalVariables.false
log-levelThe log level. Accepted values: - debug - info - warn - error Debug messages will always be sent to the internal debug system. Error messages will always fail the action. info
missing-var-actionThe behavior if variable is not found. Accepted values: - none: replace the token with an empty string and log a message - keep: leave the token and log a message - replace: replace with the value from missing-var-default and do not log a message none
missing-var-defaultDefault value when variable is not found.""
missing-var-logThe level to log key not found messages. Accepted values: - off - warn - error warn
no-telemetryOpt out of the anonymous telemetry feature. You can also set the 'REPLACETOKENS_TELEMETRY_OPTOUT' environment variable to '1' or 'true'. false
recursiveEnable token replacements in values recusively.false
rootThe root path to use when reading files with a relative path.${{ github.workspace }}
separatorThe separtor to use when flattening keys in variables. Example: '{ "key": { "array": ["a1", "a2"], "sub": "s1" } }' will be flatten as '{ "key.array.0": "a1", "key.array.1": "a2", "key.sub": "s1" }' .
token-patternThe token pattern to use. Accepted values: - default: #{ ... }# - azpipelines: $( ... ) - custom: token-prefix ... token-suffix - doublebraces: {{ ... }} - doubleunderscores: __ ... __ - githubactions: #{{ ... }} - octopus: #{ ... } default
token-prefixThe token prefix when using 'custom' token pattern.
token-suffixThe token suffix when using 'custom' token pattern.
transformsEnable transforms on values. The syntax to apply transform on a value is '#{<transform>(<name>[,<parameters>])}#'. Supported transforms: - base64(name): base64 encode the value - indent(name[, size, firstline]): indent lines in the value where size is the indent size (default is '2') and firstline specifies if the first line must be indented also (default is 'false') - lower(name): lowercase the value - raw(name): raw value (disable escaping) - upper(name): uppercase the value Example: 'key=#{upper(KEY1)}#' with '{ "KEY1": "value1" }' will result in 'key=VALUE1' false
transforms-prefixThe tranforms prefix when using transforms.(
transforms-suffixThe tranforms suffix when using transforms.)
namedescription
defaultsNumber of tokens replaced by the default value.
filesNumber of files processed.
replacedNumber of tokens replaced with a value.
tokensNumber of tokens found.
transformsNumber of transforms applied.