Skip to content

Commit 3693253

Browse files
committed
feat: add GitHub Actions workflow to automate Terraform apply on infrastructure changes.
Signed-off-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>
1 parent 81b5ba2 commit 3693253

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

.github/workflows/infra.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Terraform Apply on Changes
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'infra/**'
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- 'infra/**'
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
terraform:
24+
name: Terraform
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Authenticate with Google Cloud
32+
uses: google-github-actions/auth@v2
33+
with:
34+
project_id: 'httparchive'
35+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
36+
37+
- name: Set up Terraform
38+
uses: hashicorp/setup-terraform@v3.1.2
39+
40+
- name: Terraform Format Check
41+
working-directory: ./infra
42+
run: terraform fmt -check
43+
44+
- name: Initialize Terraform
45+
working-directory: ./infra
46+
run: terraform init
47+
48+
- name: Validate Terraform
49+
working-directory: ./infra
50+
run: terraform validate
51+
52+
- name: Plan Terraform
53+
working-directory: ./infra
54+
run: terraform plan -out=tfplan
55+
56+
- name: Apply Terraform
57+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
58+
working-directory: ./infra
59+
run: terraform apply -auto-approve tfplan

dataform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The test repository is used [for development and testing purposes](https://cloud
66

77
Pipeline can be [run manually](https://cloud.google.com/dataform/docs/code-lifecycle) from the Dataform UI.
88

9-
[Configuration](./tf/dataform.tf)
9+
[Configuration](./infra/dataform.tf)
1010

1111
## Dataform Development Workspace
1212

0 commit comments

Comments
 (0)