This GitHub Action substitutes the values of environment variables in your files using envsubst
, a powerful utility from GNU gettext.
It provides a flexible and efficient way to dynamically update configuration files, templates, and other text-based resources in your CI/CD pipeline.
-
Simplify Configuration Management: Easily update configuration files with environment-specific values without manual intervention.
-
Enhance CI/CD Workflows: Seamlessly integrate dynamic content substitution into your GitHub Actions pipelines.
-
Flexible File Handling: Process single files or multiple files using patterns, adapting to various project structures.
-
Maintain Security: Keep sensitive data in GitHub Secrets and inject them safely into your files during the CI/CD process.
-
Reduce Human Error: Automate the process of updating environment-specific values, minimizing the risk of manual mistakes.
-
Your repository must be checked out using
actions/checkout@v4
or a similar action. -
Familiarity with environment variables and GitHub Actions workflows.
This example demonstrates how to substitute environment variables in a specific file:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Substitute environment variables
uses: actions-able/envsubst-action@v1
with:
input-file: 'deployment.yaml'
output-file: 'new-deployment.yaml'
env:
IMAGE_NAME: 'my-custom-image:1.0.0'
This example shows how to process multiple files matching a specific pattern:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Substitute environment variables in multiple files
uses: actions-able/envsubst-action@v1
with:
input-file-pattern: '*.yaml'
output-file-suffix: '.subst'
env:
IMAGE_NAME: 'my-custom-image:1.0.0'
In this configuration, output filenames will have the .subst
suffix (e.g., deployment.yaml.subst
).
Name | Description | Default value | ||
---|---|---|---|---|
working-directory |
Directory where to find the input file(s) |
|
||
input-file |
Path to the input file. Requires
|
|||
output-file |
Path to the output file. Requires |
|||
input-file-pattern |
Pattern of input files. Uses GNU
|
|||
output-file-suffix |
Suffix added to filenames for output files when using |
|
For more details on envsubst
, refer to the GNU gettext documentation.