Skip to content

Fail the Apply step when tf apply fails - #29

Merged
gsavage merged 1 commit into
mainfrom
pipefail
Jul 27, 2026
Merged

Fail the Apply step when tf apply fails#29
gsavage merged 1 commit into
mainfrom
pipefail

Conversation

@gsavage

@gsavage gsavage commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Problem

The Apply step pipes tf apply into tee so the output can be captured for the Kosli attestation:

run: tf apply 2>&1 | tee /tmp/${{ inputs.environment }}.apply.txt

GitHub Actions' default shell on Linux is bash -e {0} — errexit, but not pipefail. The step's
exit status was therefore tee's (effectively always 0), so a failed tf apply left the step
green
.

The job did eventually fail, but in the wrong place: Apply summary greps the captured output for
Apply complete!, which exits 1 when the apply didn't complete. The result was a confusing red
"Apply summary" sitting under a green "Apply".

Fix

Set shell: bash explicitly on the step. That makes Actions use
bash --noprofile --norc -eo pipefail {0}, so a non-zero exit from tf apply propagates through the
pipe and fails the step — and the overall job — at the point the failure actually happened.

This is the only piped run: in the workflow, so no other steps are affected.

🤖 Generated with Claude Code

The Apply step pipes tf apply into tee so the output can be captured for
the Kosli attestation. GitHub Actions' default shell on Linux is
"bash -e {0}", which sets errexit but not pipefail, so the step's exit
status was tee's rather than tf's. A failed apply therefore left the
step green, and the job only broke later in "Apply summary" when its
grep for "Apply complete!" found nothing - reporting the failure in the
wrong place.

Setting "shell: bash" explicitly makes Actions use
"bash --noprofile --norc -eo pipefail {0}", so a non-zero exit from
tf apply now fails the step and the overall job.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gsavage
gsavage merged commit 179d090 into main Jul 27, 2026
1 check passed
@gsavage
gsavage deleted the pipefail branch July 27, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants