Skip to content

envsubst-gnu-utility

Actions
Substitutes the values of environment variables in one file or in multiple files following patterns
v1.2.0
Latest
Star (3)

Tags

 (1)

Envsubst GitHub Action

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.

Why Use This Action?

  • 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.

Prerequisites

  • Your repository must be checked out using actions/checkout@v4 or a similar action.

  • Familiarity with environment variables and GitHub Actions workflows.

Usage Examples

Substitute envs in a single file

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'

Substitute envs in multiple files using patterns

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).

Parameters

Name Description Default value

working-directory

Directory where to find the input file(s)

.

input-file

Path to the input file. Requires output-file to be set if defined.

Note
Cannot be used with input-file-pattern.

output-file

Path to the output file. Requires input-file to be set if defined.

input-file-pattern

Pattern of input files. Uses GNU find -name for file matching.

Note
Cannot be used with input-file.

output-file-suffix

Suffix added to filenames for output files when using input-file-pattern.

.subst

Additional Information

For more details on envsubst, refer to the GNU gettext documentation.

envsubst-gnu-utility 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

Substitutes the values of environment variables in one file or in multiple files following patterns
v1.2.0
Latest

Tags

 (1)

envsubst-gnu-utility 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.