Skip to content

changing it to be conditional #6

changing it to be conditional

changing it to be conditional #6

Workflow file for this run

name: 'Terraform Apply'
on:
push:
branches: [ "deploy" ]
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
terraform-apply:
name: 'Terraform Apply'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: "${{ secrets.AWS_ARN }}"
aws-region: us-east-1
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
- name: Terraform Init
run: terraform init
working-directory: terraform
- name: Terraform Plan
id: terraform-plan
run: |
terraform plan -input=false -out=tfplan
echo ::set-output name=has_changes::$(terraform show -json tfplan | jq -r '.resource_changes | length > 0')
working-directory: terraform
- name: Conditional Terraform Apply
if: steps.terraform-plan.outputs.has_changes == 'true'
run: terraform apply -auto-approve tfplan
working-directory: terraform