Skip to content

feat!: apply the reviewed plan behind an environment gate - #6

Merged
Krustytoe merged 1 commit into
mainfrom
fix/pinning-and-reviewed-plan-apply
Oct 15, 2026
Merged

Krustytoe merged 1 commit into
mainfrom
fix/pinning-and-reviewed-plan-apply

Conversation

@Krustytoe

Copy link
Copy Markdown
Owner

Fixes three issues in the Terraform workflows.

1. Internal composite actions were referenced at @main

terraform-plan.yml and terraform-apply.yml called this repo's own actions at @main, which contradicts the README's own "avoid @main" guidance: a SHA-pinned caller still pulled unpinned code. They now use the release tag with # x-release-please-version, and release-please-config.json lists both workflows in extra-files so each release PR bumps them.

2. Apply ran a fresh, unreviewed plan

terraform-apply ran apply -auto-approve, so what got applied could differ from what was reviewed. Now:

  • terraform-plan uses -detailed-exitcode, exposes a has_changes output, writes the plan to the job summary, and with upload_plan: true saves the plan file as an artifact (1-day retention, since plan files can contain sensitive values in plaintext).
  • terraform-apply downloads that artifact and runs terraform apply tfplan. If state drifted after the plan, Terraform rejects the stale plan.

3. The documented approval gate couldn't work

The README put environment: prod on the job that calls the reusable workflow. GitHub doesn't support environment on caller jobs (supported keywords). terraform-apply now takes a required environment input and declares it on the apply job. That also produces the repo:<org>/<repo>:environment:<name> OIDC subject claim that the github-oidc-role modules trust.

Breaking change

environment is now a required input on terraform-apply. bump-minor-pre-major is enabled, so this releases as v0.3.0, not 1.0.0.

Validation

  • actionlint 1.7.12 (same version as CI): clean
  • README: updated diagram, design decisions, input/output tables, and a full plan → approve → apply example with separate plan/apply roles

🤖 Generated with Claude Code

- terraform-plan: -detailed-exitcode, has_changes output, plan in job
  summary, optional upload of the saved plan (upload_plan, 1-day retention)
- terraform-apply: required `environment` input declared on the apply job
  (GitHub rejects environment: on a job that calls a reusable workflow);
  plan_artifact_name applies the exact saved plan; falls back to a fresh
  plan with a warning when omitted
- fix: reference this repo's composite actions at the release tag instead
  of @main; release-please now bumps them via extra-files
- release-please: bump-minor-pre-major so breaking changes stay in 0.x

BREAKING CHANGE: terraform-apply requires an `environment` input. Move
`environment:` from the calling job into `with:`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Krustytoe
Krustytoe merged commit c821236 into main Oct 15, 2026
1 check passed
@Krustytoe
Krustytoe deleted the fix/pinning-and-reviewed-plan-apply branch October 15, 2026 15:21
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.

1 participant