Skip to content

Commit d6df663

Browse files
feat(tf): Add a reusable workflow to run terraform apply (#16)
1 parent cb77710 commit d6df663

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.github/workflows/merge_tf.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: "Terraform: Apply Changes"
3+
4+
"on":
5+
workflow_call:
6+
jobs:
7+
terraform:
8+
name: "Terraform"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- id: repo_checkout
12+
name: "Repository: Checkout"
13+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
14+
- id: tf_version
15+
name: "Terraform: Get version"
16+
run: |
17+
TF_VERSION=$(cat .terraform-version 2>/dev/null || echo latest)
18+
echo "TF_VERSION=$TF_VERSION" >> $GITHUB_OUTPUT
19+
- id: tf_setup
20+
name: "Terraform: Setup"
21+
uses: hashicorp/setup-terraform@97f030cf6dc0b4f5e0da352c7bca9cca34579800 # v3.1.0
22+
with:
23+
terraform_version: ${{steps.tf_version.outputs.TF_VERSION}}
24+
- id: tf_init
25+
name: "Terraform: Prepare working directory"
26+
run: terraform init
27+
- id: tf_apply
28+
name: "Terraform: Apply terraform plan"
29+
run: terraform apply -auto-approve -input=false -no-color

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,17 @@ jobs:
6161
uses: scaleway-terraform-modules/wokflows/.github/workflows/check_yaml.yaml@main
6262

6363
```
64+
65+
## merge_tf.yaml
66+
67+
Apply any changes on the infrastructure.
68+
69+
Include the following jobs in your existing workflows to use the workflow:
70+
```yaml
71+
[...]
72+
jobs:
73+
merge_tf:
74+
uses: scaleway-terraform-modules/wokflows/.github/workflows/merge_tf.yaml@main
75+
secrets: inherit
76+
77+
```

0 commit comments

Comments
 (0)