Skip to content

Commit

Permalink
[Bugfix] Fix deployment logic (#4)
Browse files Browse the repository at this point in the history
- fixes #2
  • Loading branch information
sidpalas authored May 28, 2021
1 parent 2e3891b commit 3b6a954
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,25 @@ jobs:
- name: Check tag
id: check-tag
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/vd+\.d+\.d+$ ]]; then echo ::set-output name=environment::production
elif [[ github.ref == 'refs/heads/main' ]]; then echo ::set-output name=environment::staging
if [[ ${{ github.ref }} =~ "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$" ]]; then echo ::set-output name=environment::production
elif [[ ${{ github.ref }} == 'refs/heads/main' ]]; then echo ::set-output name=environment::staging
else echo ::set-output name=environment::unknown
fi
- name: Terraform Apply Global
if: github.event_name == 'push'
working-directory: 07-managing-multiple-environments/file-structure/global
run: |
terraform init
terraform apply -auto-approve
- name: Terraform Apply Staging
if: steps.check-tag.outputs.environment == 'production' && github.event_name == 'push'
working-directory: 07-managing-multiple-environments/file-structure/staging
if: steps.check-tag.outputs.environment == 'staging' && github.event_name == 'push'
run: terraform apply -var db_pass=${{secrets.DB_PASS }} -auto-approve

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

0 comments on commit 3b6a954

Please sign in to comment.