pr validation terraform #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pr validation terraform | |
on: | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
env: | |
AWS_ACCESS_KEY_ID: "${{secrets.AWS_ACCESS_KEY_ID}}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
AWS_REGION: "${{ secrets.AWS_REGION }}" | |
concurrency: | |
group: ${{github.workflow}} | |
cancel-in-progress: true | |
jobs: | |
terraform-plan: | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
terraform: [0.14.8] | |
steps: | |
- name: checkout 🛎 | |
uses: actions/checkout@master | |
- name: Aws credentions | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Setup Terrafom | |
uses: hashicorp/[email protected] | |
with: | |
terraform_version: ${{ matrix.terraform }} | |
- name: Terraform Init | |
id: tf_init | |
run: terraform init | |
- name: Terraform Validade | |
id: tf_validate | |
run: terraform validate -no-color | |
- name: terraform plan | |
id: tf-plan | |
run: terraform plan -out=plan.out -input=false -lock=false | |
continue-on-error: true | |
- name: terraform show plan | |
id: tf_show | |
run: terraform show -no-color plan.out | |
continue-on-error: true | |
- name: Terraform Plan Status | |
if: steps.tf_plan.outcome == 'failure' | |
run: exit 1 |