From 7356c9d934ce6e66d750d1ce8e7261604b9652ae Mon Sep 17 00:00:00 2001 From: Graham Savage Date: Fri, 28 Aug 2026 11:02:02 +0100 Subject: [PATCH] Keep the plan summary working for outputs-only plans The "Plan summary" step grepped the saved plan for "No changes." or "Plan: " and assigned the match to a variable. GitHub Actions runs `run:` blocks under `bash -e`, so when neither pattern was present grep exited 1 and failed the whole job. Terraform prints neither of those lines when a plan changes only outputs; it prints "Changes to Outputs:" instead. Any change that adds or edits an output without touching resources therefore broke the plan workflow for callers. Tolerate a non-matching grep and fall back to the outputs header, then to a generic message pointing at the uploaded plan. has_changes is unchanged in meaning: an outputs-only plan has no "No changes." line, so it still reports true and the apply job still runs. --- .github/workflows/base.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 07e5a8b..e8dfc4c 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -164,12 +164,22 @@ jobs: - name: Plan summary id: plan-summary run: | - line=$(grep -E 'No changes\.|Plan: ' /tmp/${{ inputs.environment }}.plan.txt) + # A plan that changes only outputs has neither a "Plan:" line nor + # "No changes.", so fall back to the outputs header and then to a + # generic message rather than letting grep fail the step. + plan=/tmp/${{ inputs.environment }}.plan.txt + line=$(grep -E 'No changes\.|Plan: ' "$plan" || true) + if [ -z "$line" ]; then + line=$(grep -E 'Changes to Outputs:' "$plan" || true) + fi + if [ -z "$line" ]; then + line="See the uploaded plan for details." + fi { echo "### ${{ inputs.environment }}" echo "$line" } >> "$GITHUB_STEP_SUMMARY" - if grep -q 'No changes\.' /tmp/${{ inputs.environment }}.plan.txt; then + if grep -q 'No changes\.' "$plan"; then echo "has_changes=false" >> "$GITHUB_OUTPUT" else echo "has_changes=true" >> "$GITHUB_OUTPUT"