Skip to content

Substitute environment variables in files in Github Actions

License

Notifications You must be signed in to change notification settings

nightstory/replace-env

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Replace environment variables in files in a GitHub Action

Inputs

  • input_file
    • Path to file with the placeholders to replace. If directory, will replace all files in the directory.
  • output_file
    • Path to output file. If input_file is directory, will be a directory too.
    • Optional, defaults to input_file
  • pattern
    • Which placeholders to replace.
    • Options:
      • single_dollar_brackets -> ${VARIABLE}
      • double_dollar_brackets -> ${{VARIABLE}}
      • double_underscore -> __VARIABLE__
    • Optional, defaults to single_dollar_brackets
  • fail_on_missing_env
    • If true, will fail if a key required in the input file is missing in the environment.
    • default: false

Example usage

The input_file:

{
  "foo": "${FOO_BAR_123}"
}

⚠️ no spaces around the key.

The workflow:

name: whatever

env:
  FOO_BAR_123: 'literally whatever'

The result:

{
  "foo": "literally whatever"
}

License

Licensed under MIT license.
Please also see licenses.txt