1+ name : terraform-oidc
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches : [ "main" ]
7+ paths :
8+ - " infra/workload/01-local-state/**"
9+ - " .github/workflows/terraform.yml"
10+
11+ permissions :
12+ id-token : write
13+ contents : read
14+
15+ env :
16+ TF_IN_AUTOMATION : true
17+ TF_INPUT : false
18+ TF_WORKING_DIR : infra/workload/01-local-state
19+
20+ jobs :
21+ plan :
22+ runs-on : ubuntu-latest
23+ defaults :
24+ run :
25+ shell : bash
26+ working-directory : ${{ env.TF_WORKING_DIR }}
27+
28+ steps :
29+ - name : Checkout
30+ uses : actions/checkout@v4
31+
32+ - name : Setup Terraform
33+ uses : hashicorp/setup-terraform@v3
34+ with :
35+ terraform_version : 1.6.6
36+
37+ - name : Azure Login (OIDC)
38+ uses : azure/login@v2
39+ with :
40+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
41+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
42+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
43+
44+ - name : Terraform Init
45+ run : terraform init
46+
47+ - name : Terraform Validate
48+ run : terraform validate
49+
50+ - name : Terraform Plan
51+ run : terraform plan -lock-timeout=0s
52+
53+ apply :
54+ needs : plan
55+ runs-on : ubuntu-latest
56+ if : github.event_name == 'workflow_dispatch'
57+ defaults :
58+ run :
59+ shell : bash
60+ working-directory : ${{ env.TF_WORKING_DIR }}
61+
62+ steps :
63+ - name : Checkout
64+ uses : actions/checkout@v4
65+
66+ - name : Setup Terraform
67+ uses : hashicorp/setup-terraform@v3
68+ with :
69+ terraform_version : 1.6.6
70+
71+ - name : Azure Login (OIDC)
72+ uses : azure/login@v2
73+ with :
74+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
75+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
76+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
77+
78+ - name : Terraform Init
79+ run : terraform init
80+
81+ - name : Terraform Apply
82+ run : terraform apply -auto-approve -lock-timeout=0s
0 commit comments