action-terraform-copy-vars
GitHub Action automatically copying variables' definitions from a single file to many modules
10K+
GitHub Action automatically copying variables' definitions from a single file to many modules.
all_vars_file and will use whole definitions of variables from it.dirs_with_modules will search files matching files_with_vars and replace matching variables from all_vars_file.Perfect for automation workflows and integrates seamlessly with devops-infra/action-commit-pushโ .
This action supports three tag levels for flexible versioning:
vX: latest patch of the major version (e.g., v1).vX.Y: latest patch of the minor version (e.g., v1.2).vX.Y.Z: fixed to a specific release (e.g., v1.2.3). - name: Run the action
uses: devops-infra/[email protected]
with:
dirs_with_modules: modules
files_with_vars: variables.tf
all_vars_file: all-variables.tf
fail_on_missing: false
| Input Variable | Required | Default | Description |
|---|---|---|---|
dirs_with_modules | No | terraform | Comma separated list of directory prefixes with modules. |
files_with_vars | No | variables.tf | Comma separated list of files containing variables in directories matching dirs_with_modules. |
all_vars_file | No | all-variables.tf | Name of a file containing base definitions of all variables. |
fail_on_missing | No | false | Whether action should fail if all_vars_file is missing some definitions from modules. |
Fail action if not all variables in variables.tf in terraform subdirectories match their definitions in all-variables.tf.
name: Check Terraform variables
on:
push
jobs:
terraform-copy-vars:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Fail on different variables' definitions
uses: devops-infra/[email protected]
with:
fail_on_changes: true
Copy variables definitions from all-variables.tf to all variables.tf in modules subdirectories and commit updated files back to the repository using my other action devops-infra/action-commit-pushโ .
name: Copy Terraform variables across modules
on:
push
jobs:
terraform-copy-vars:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Update Terraform variables
uses: devops-infra/[email protected]
with:
dirs_with_modules: modules
files_with_vars: variables.tf
all_vars_file: all-variables.tf
- name: Commit changes to repo
uses: devops-infra/action-commit-push@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_prefix: "[AUTO-VARIABLES]"
Pick the tag level based on your stability needs:
vX.Y.Z: exact immutable release (most predictable)vX.Y: latest patch within one minor linevX: latest patch within one major linename: Use pinned action version
on: [push]
jobs:
terraform-copy-vars:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: devops-infra/[email protected]
id: pin-patch
- uses: devops-infra/[email protected]
id: pin-minor
- uses: devops-infra/action-terraform-copy-vars@v1
id: pin-major
Contributions are welcome! See CONTRIBUTINGโ . This project is licensed under the MIT License - see the LICENSEโ file for details.
This project is licensed under the MIT License - see the LICENSEโ file for details.
If you have any questions or need help, please:
Use the manual workflow .github/workflows/manual-e2e-validate.yml to validate this action against the centralized E2E repository.
mode=image validates a published image tag (recommended for -test and -rc release checks).mode=ref validates ref-oriented E2E paths against stable pinned action refs.CI/CD automation also runs these E2E checks automatically:
-rc).Example trigger inputs:
mode=ref
mode=image
image_tag=v1.2.3-test
To publish images from a fork, set these variables so Task uses your registry identities:
DOCKER_USERNAME, DOCKER_ORG_NAME, GITHUB_USERNAME, GITHUB_ORG_NAME.
Two supported options (environment variables take precedence over .env):
# .env (local only, not committed)
DOCKER_USERNAME=your-dockerhub-user
DOCKER_ORG_NAME=your-dockerhub-org
GITHUB_USERNAME=your-github-user
GITHUB_ORG_NAME=your-github-org
# Shell override
DOCKER_USERNAME=your-dockerhub-user \
DOCKER_ORG_NAME=your-dockerhub-org \
GITHUB_USERNAME=your-github-user \
GITHUB_ORG_NAME=your-github-org \
task docker:build
Recommended setup:
.env file.DOCKER_TOKEN and GITHUB_TOKEN.Publish images without a release:
(Manual) Release Create workflow with build_only: true to build and push images without tagging a release.Content type
Image
Digest
sha256:cf759e3adโฆ
Size
28.9 MB
Last updated
2 days ago
docker pull devopsinfra/action-terraform-copy-vars:latest-testPulls:
7,942
Last week