11name : Terraform CI/CD - LiveKit Infra
22
33on :
4- workflow_dispatch :
4+ workflow_dispatch : # allow manual trigger
55 pull_request :
66 paths :
77 - ' livekit/infra/**'
1313
1414permissions :
1515 contents : ' read' # needed by checkout
16- id-token : ' write' # only if you use OIDC (not required here)
16+ id-token : ' write' # only if you use OIDC (optional here)
1717
1818jobs :
1919 terraform-plan :
20- name : Terraform Plan (PRs & push)
20+ name : Terraform Plan
2121 runs-on : ubuntu-latest
22- if : github.event_name == 'pull_request' || github.event_name == 'push'
2322 steps :
2423 - name : Checkout repo
2524 uses : actions/checkout@v4
4140 - name : Create terraform.tfvars from secrets
4241 working-directory : livekit/infra
4342 run : |
44- # Create terraform.tfvars dynamically (values come from repo secrets)
4543 cat > terraform.tfvars <<'TFVARS'
4644 aws_region = "${{ secrets.AWS_REGION }}"
4745 tfstate_s3_bucket = "${{ secrets.TFSTATE_S3_BUCKET }}"
7169
7270 - name : Terraform Plan
7371 working-directory : livekit/infra
74- run : |
75- terraform plan -input=false -var-file="terraform.tfvars" -out=tfplan
72+ run : terraform plan -input=false -var-file="terraform.tfvars" -out=tfplan
73+
7674 - name : Upload plan artifact (optional)
7775 if : github.event_name == 'pull_request'
7876 uses : actions/upload-artifact@v4
@@ -81,10 +79,10 @@ jobs:
8179 path : livekit/infra/tfplan
8280
8381 terraform-apply :
84- name : Terraform Apply (main)
82+ name : Terraform Apply
8583 runs-on : ubuntu-latest
8684 needs : terraform-plan
87- if : github.ref == 'refs/heads/main'
85+ if : github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
8886 steps :
8987 - name : Checkout repo
9088 uses : actions/checkout@v4
0 commit comments