Skip to content

Commit d0bc530

Browse files
committed
tf flow fixes
1 parent 9088a8d commit d0bc530

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

.github/workflows/terraform-gcs.yaml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
name: 'Terraform-GCS'
22

33
on:
4-
workflow_call:
5-
secrets:
6-
GCP_SA_KEY:
4+
workflow_dispatch:
5+
inputs:
6+
terraform_directory:
7+
description: 'Path to Terraform directory (e.g., gcp/terraform)'
78
required: true
9+
type: string
10+
default: 'gcp/terraform'
11+
state_prefix:
12+
description: 'Prefix for Terraform state (e.g., iam)'
13+
required: true
14+
type: string
15+
default: 'iam'
16+
17+
env:
18+
TF_VAR_TFC_GCP_PROVIDER_AUTH: ${{ secrets.TFC_GCP_PROVIDER_AUTH }}
19+
TF_VAR_TFC_GCP_RUN_SERVICE_ACCOUNT_EMAIL: ${{ secrets.TFC_GCP_RUN_SERVICE_ACCOUNT_EMAIL }}
20+
TF_VAR_TFC_GCP_WORKLOAD_PROVIDER_NAME: ${{ secrets.TFC_GCP_WORKLOAD_PROVIDER_NAME }}
21+
822
permissions:
923
contents: read
1024
id-token: write
@@ -20,6 +34,9 @@ jobs:
2034
shell: bash
2135

2236
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
2340
- name: Authenticate to Google Cloud
2441
id: auth
2542
uses: google-github-actions/auth@v1
@@ -43,33 +60,25 @@ jobs:
4360

4461
- name: Clear Terraform cache
4562
run: |
46-
# Remove all cached Terraform files
4763
rm -rf ~/.terraform.d/
4864
rm -rf ~/.terraformrc
4965
rm -rf .terraform/
5066
rm -f .terraform.lock.hcl
51-
working-directory: gcp/terraform
67+
working-directory: ${{ inputs.terraform_directory }}
5268

5369
- name: Terraform Init
54-
working-directory: gcp/terraform
70+
working-directory: ${{ inputs.terraform_directory }}
5571
run: |
5672
terraform init \
5773
-backend-config="bucket=common-tools-terraform-state" \
58-
-backend-config="prefix=iam" \
74+
-backend-config="prefix=${{ inputs.state_prefix }}" \
5975
-reconfigure \
6076
-input=false
61-
env:
62-
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
63-
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_HOST }}
77+
6478
- name: Terraform Plan
65-
working-directory: gcp/terraform
79+
working-directory: ${{ inputs.terraform_directory }}
6680
run: terraform plan -input=false
67-
env:
68-
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
69-
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_HOST }}
81+
7082
- name: Terraform Apply
71-
working-directory: gcp/terraform
83+
working-directory: ${{ inputs.terraform_directory }}
7284
run: terraform apply -auto-approve -input=false
73-
env:
74-
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
75-
OP_CONNECT_HOST: ${{ secrets.OP_CONNECT_HOST }}

0 commit comments

Comments
 (0)