Skip to content

Commit 1acd6aa

Browse files
authored
Add variablized example (hashicorp#149)
* Add variablized example Maybe this is too much hand holding, but these actions tend to be relatively repetitive wrt inputs that they need and those inputs should pretty much always be variablized. This PR provides an example of how to variablize things like the working directory and the TF version so they are managed in a single assignment rather than 2-6 assignments. * Update README.md Co-Authored-By: Matthew Sanabria <[email protected]> Co-authored-by: Matthew Sanabria <[email protected]>
1 parent 45b8cb0 commit 1acd6aa

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ The most common workflow is to run `terraform fmt`, `terraform init`, `terraform
1818
name: 'Terraform GitHub Actions'
1919
on:
2020
- pull_request
21+
env:
22+
tf_version: 'latest'
23+
tf_working_dir: '.'
2124
jobs:
2225
terraform:
2326
name: 'Terraform'
@@ -28,36 +31,36 @@ jobs:
2831
- name: 'Terraform Format'
2932
uses: hashicorp/terraform-github-actions@master
3033
with:
31-
tf_actions_version: 0.12.13
34+
tf_actions_version: ${{ env.tf_version }}
3235
tf_actions_subcommand: 'fmt'
33-
tf_actions_working_dir: '.'
36+
tf_actions_working_dir: ${{ env.tf_working_dir }}
3437
tf_actions_comment: true
3538
env:
3639
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3740
- name: 'Terraform Init'
3841
uses: hashicorp/terraform-github-actions@master
3942
with:
40-
tf_actions_version: 0.12.13
43+
tf_actions_version: ${{ env.tf_version }}
4144
tf_actions_subcommand: 'init'
42-
tf_actions_working_dir: '.'
45+
tf_actions_working_dir: ${{ env.tf_working_dir }}
4346
tf_actions_comment: true
4447
env:
4548
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4649
- name: 'Terraform Validate'
4750
uses: hashicorp/terraform-github-actions@master
4851
with:
49-
tf_actions_version: 0.12.13
52+
tf_actions_version: ${{ env.tf_version }}
5053
tf_actions_subcommand: 'validate'
51-
tf_actions_working_dir: '.'
54+
tf_actions_working_dir: ${{ env.tf_working_dir }}
5255
tf_actions_comment: true
5356
env:
5457
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5558
- name: 'Terraform Plan'
5659
uses: hashicorp/terraform-github-actions@master
5760
with:
58-
tf_actions_version: 0.12.13
61+
tf_actions_version: ${{ env.tf_version }}
5962
tf_actions_subcommand: 'plan'
60-
tf_actions_working_dir: '.'
63+
tf_actions_working_dir: ${{ env.tf_working_dir }}
6164
tf_actions_comment: true
6265
env:
6366
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)