An open API service indexing awesome lists of open source software.

https://github.com/actions-able/envsubst-action

Github action of envsubst (utility of GNU gettext https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html)
https://github.com/actions-able/envsubst-action

github-actions hacktoberfest utility

Last synced: 4 months ago
JSON representation

Github action of envsubst (utility of GNU gettext https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html)

Awesome Lists containing this project

README

        

= 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:

[source,yaml]
----
- 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:

[source,yaml]
----
- 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

[cols="2a,6a,1a",options="header"]
|===
|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 https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html[GNU gettext documentation].