From 50318ae1d2da314497454fd9b6413018db65f630 Mon Sep 17 00:00:00 2001 From: Andrew Dryga Date: Tue, 23 Jul 2024 09:18:49 -0600 Subject: [PATCH] chore(ci): Do not run terraform plan in PRs when there are no changes (#5964) --- .github/workflows/_terraform.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/_terraform.yml b/.github/workflows/_terraform.yml index 0eaaa11bb..ca1857e0d 100644 --- a/.github/workflows/_terraform.yml +++ b/.github/workflows/_terraform.yml @@ -32,7 +32,14 @@ jobs: working-directory: terraform run: | terraform fmt --check --recursive - - name: Upload Configuration + - uses: dorny/paths-filter@v3 + id: changes + with: + filters: | + terraform: + - 'terraform/**' + - if: steps.changes.outputs.terraform == 'true' + name: Upload Configuration uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.3.0 id: plan-upload with: @@ -41,7 +48,8 @@ jobs: # https://app.terraform.io/app/firezone/workspaces/staging/settings/general directory: "./" speculative: true - - name: Create Plan Run + - if: steps.changes.outputs.terraform == 'true' + name: Create Plan Run uses: hashicorp/tfc-workflows-github/actions/create-run@v1.3.0 id: plan-run env: @@ -51,7 +59,8 @@ jobs: configuration_version: ${{ steps.plan-upload.outputs.configuration_version_id }} plan_only: true - - name: Get Plan Output + - if: steps.changes.outputs.terraform == 'true' + name: Get Plan Output uses: hashicorp/tfc-workflows-github/actions/plan-output@v1.3.0 id: plan-output with: @@ -59,7 +68,7 @@ jobs: - name: Update PR uses: actions/github-script@v7 id: plan-comment - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && steps.changes.outputs.terraform == 'true' }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: |