mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-10 12:51:14 +00:00
add test on branch
This commit is contained in:
25
.github/workflows/terraform.yml
vendored
25
.github/workflows/terraform.yml
vendored
@@ -4,6 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- feature/test-filters
|
||||||
|
tags:
|
||||||
|
- v\d+\.\d+\.\d+$
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -36,7 +39,7 @@ jobs:
|
|||||||
- name: Terraform Plan
|
- name: Terraform Plan
|
||||||
id: plan
|
id: plan
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
run: terraform plan -no-color
|
run: terraform plan -var db_pass=${{secrets.DB_PASS }} -no-color
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- uses: actions/github-script@0.9.0
|
- uses: actions/github-script@0.9.0
|
||||||
@@ -70,6 +73,20 @@ jobs:
|
|||||||
if: steps.plan.outcome == 'failure'
|
if: steps.plan.outcome == 'failure'
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|
||||||
# - name: Terraform Apply
|
- name: Check tag
|
||||||
# if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
id: check-tag
|
||||||
# run: terraform apply -auto-approve
|
run: |
|
||||||
|
if [[ ${{ github.ref }} =~ "^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$" ]]; then echo ::set-output name=environment::production
|
||||||
|
elif [[ ${{ github.ref }} == 'refs/heads/feature/test-filters' ]]; then echo ::set-output name=environment::staging
|
||||||
|
else echo ::set-output name=environment::unknown
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Terraform Apply Staging
|
||||||
|
if: steps.check-tag.outputs.environment == 'production' && github.event_name == 'push'
|
||||||
|
working-directory: 07-managing-multiple-environments/file-structure/staging
|
||||||
|
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'
|
||||||
|
working-directory: 07-managing-multiple-environments/file-structure/production
|
||||||
|
run: terraform apply -var db_pass=${{secrets.DB_PASS }} -auto-approve
|
||||||
|
|||||||
Reference in New Issue
Block a user