Skip to content

Commit 5fd2d96

Browse files
committed
2 parents 30b623b + 3b6a954 commit 5fd2d96

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

.github/workflows/terraform.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,25 @@ jobs:
7575
- name: Check tag
7676
id: check-tag
7777
run: |
78-
if [[ ${{ github.ref }} =~ ^refs/tags/vd+\.d+\.d+$ ]]; then echo ::set-output name=environment::production
79-
elif [[ github.ref == 'refs/heads/main' ]]; then echo ::set-output name=environment::staging
78+
if [[ ${{ github.ref }} =~ "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$" ]]; then echo ::set-output name=environment::production
79+
elif [[ ${{ github.ref }} == 'refs/heads/main' ]]; then echo ::set-output name=environment::staging
8080
else echo ::set-output name=environment::unknown
8181
fi
8282
83+
- name: Terraform Apply Global
84+
if: github.event_name == 'push'
85+
working-directory: 07-managing-multiple-environments/file-structure/global
86+
run: |
87+
terraform init
88+
terraform apply -auto-approve
89+
8390
- name: Terraform Apply Staging
84-
if: steps.check-tag.outputs.environment == 'production' && github.event_name == 'push'
85-
working-directory: 07-managing-multiple-environments/file-structure/staging
91+
if: steps.check-tag.outputs.environment == 'staging' && github.event_name == 'push'
8692
run: terraform apply -var db_pass=${{secrets.DB_PASS }} -auto-approve
8793

8894
- name: Terraform Apply Production
89-
if: steps.check-tag.outputs.environment == 'staging' && github.event_name == 'push'
95+
if: steps.check-tag.outputs.environment == 'production' && github.event_name == 'push'
9096
working-directory: 07-managing-multiple-environments/file-structure/production
91-
run: terraform apply -var db_pass=${{secrets.DB_PASS }} -auto-approve
97+
run: |
98+
terraform init
99+
terraform apply -var db_pass=${{secrets.DB_PASS }} -auto-approve

0 commit comments

Comments
 (0)