diff --git a/.github/workflows/tf-plan.yml b/.github/workflows/tf-plan.yml index 07068ce..cf50360 100644 --- a/.github/workflows/tf-plan.yml +++ b/.github/workflows/tf-plan.yml @@ -2,9 +2,6 @@ name: Terraform Plan (PR) on: pull_request: - paths: - - src/tf/** - - .github/workflows/tf-plan.yml permissions: contents: read @@ -12,13 +9,33 @@ permissions: pull-requests: write jobs: + changes: + runs-on: ubuntu-latest + outputs: + terraform: ${{ steps.changed-files.outputs.any_changed }} + steps: + - uses: actions/checkout@v7 + + - name: Detect Terraform changes + id: changed-files + uses: tj-actions/changed-files@v47 + with: + files: | + src/tf/** + .github/workflows/tf-plan.yml + validate: + needs: changes + if: ${{ needs.changes.outputs.terraform == 'true' }} uses: glitchedmob/infra-gha/.github/workflows/tf-validate.yml@v0.7.4 with: init-backend: false plan: - needs: validate + needs: + - changes + - validate + if: ${{ needs.changes.outputs.terraform == 'true' }} uses: glitchedmob/infra-gha/.github/workflows/tf-plan-apply.yml@v0.7.4 with: plan-only: true @@ -27,3 +44,17 @@ jobs: export TF_VAR_github_app_pem="${{ secrets.TF_VAR_GITHUB_APP_PEM }}" aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} output_encryption_key: ${{ secrets.OUTPUT_ENCRYPTION_KEY }} + + result: + name: Terraform checks + if: ${{ always() }} + needs: + - changes + - validate + - plan + runs-on: ubuntu-latest + steps: + - uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # release/v1 + with: + allowed-skips: validate, plan + jobs: ${{ toJSON(needs) }}