Repository navigation
fix(ci): serialize app pipelines and keep plan and apply consistent - #186
Merged
Merged
Conversation
- javabin.yml: one pipeline per repo/ref (queued on the default branch, cancelled on superseded PR pushes); docker-build needs a successful plan when the repo has app.yaml or terraform/ - expand/tf-plan: check out the PR merge ref for fork PRs; tf-plan skips AWS steps with a notice when the run has no OIDC token - commit-generated-tf.sh: a rejected push fails with the reason and fix - tf-apply (and platform-ci apply): restore .terraform.lock.hcl from the verified plan so init installs the planned provider versions - ensure-tf-boilerplate.sh: take the broker-verified team instead of a GITHUB_TOKEN lookup that fell back to team=unknown; also run in tf-apply Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terraform Plan✅ No changes — infrastructure is up to date. Plan output |
This was referenced Oct 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Findings 9, 20 and the ensure-tf-boilerplate gap from the DX audit. In the app pipeline:
platform-ci.ymlsetconcurrency. Two quick merges ran in parallel. The second expand push could be rejected as non-fast-forward, the applies fought over the state lock, or the second apply hit a stale saved plan.docker-buildonly skipped ontf-plan == 'failure'. A brokenapp.yamlfailsexpand,tf-planis then skipped, and the image was still built and deployed. On a new repo this showed up as a misleading "ECR repository does not exist".github.head_refnames a branch that only exists in the fork. Runs without an OIDC token failed on the AWS steps..terraform.lock.hclis gitignored and the AWS provider is pinned only to~> 5.0, sotf-apply'sinitcould pick a newer provider than the plan used.gh api /repos/.../teams, whichGITHUB_TOKENcannot read, so it fell back toteam=unknown. The state key becameapps/unknown/<repo>, which no team role can access. Repos that bring their ownterraform/withoutapp.yamlbroke.Change
javabin.yml: workflow-levelconcurrencygroupjavabin-pipeline-<repo>-<ref>. GitHub honours this for called workflows. Runs on the default branch queue (cancel-in-progress: false), and a newer push to a PR cancels the older run.docker-buildnow needstf-plan == 'success'whenever the repo hasapp.yamlorterraform/.tf-applygets the team tf-plan's broker verified.tf-apply.yml: has its own concurrency group for callers outsidejavabin.yml, and uses-lock-timeout=5m. Beforeinitit restores.terraform.lock.hclfrom the saved plan. Terraform stores the lock file inside the plan, and the existing SHA256 check covers it. It also runsensure-tf-boilerplate.shwith the same team as the plan.platform-ci.ymlapply: restores the lock file the same way.expand-terraform.yml/tf-plan.yml: check outgithub.head_refonly for same-repo PRs, otherwisegithub.ref(the PR merge ref for forks). Newscripts/check-aws-access.shchecks forACTIONS_ID_TOKEN_REQUEST_URL. Without it, tf-plan posts a notice, skips the broker, plan, review and comment steps, and still runsinit -backend=false,validateandfmt -check. Plan uses-lock-timeout=5m. New outputteam.commit-generated-tf.sh: a rejected push fails with an::errorthat gives the reason and the fix. The cases are a protected branch or ruleset (GH006/GH013), a branch that moved during the run, a read-only token, or anything else. After a push to a PR it posts a notice that checks don't run on the bot commit.ensure-tf-boilerplate.sh: takesTEAMfrom the broker. If the files it needs to generate are missing and there is no team, it fails instead of writingunknown. Existing states: S3apps/has nounknown/prefix, so no state moves.docs/reusable-workflows.md(concurrency, fork/Dependabot PRs, push requirements and protected branches, lock file, boilerplate team),docs/ci-workflow.md,CLAUDE.mdscript table.Not changed: no GitHub App was added (the repo has none for app pipelines). Image tag and deploy ordering are also untouched, since another PR owns findings 7, 16 and 17.
Verification
scripts/tests/test_pipeline_scripts.py(11 tests) runs the scripts against throwaway git repos:pre-receivehook that emits GH006python3 -m unittest discover -s scripts/testspasses (144 tests).python3 -m unittest discover -s terraform/lambda-src/testspasses (219 tests).actionlinton all workflows: no new findings (one SC2129 style note indetect.ymlwas already there).shellcheck -s shon the changed scripts is clean.unzip -l tfplanlists.terraform.lock.hcl. A plan was made withhashicorp/null3.1.0 and the config then loosened to~> 3.0. A freshinitwithout the lock installed 3.3.2. Afterunzip -o tfplan .terraform.lock.hclit installed 3.1.0.cupcake/ javazoneweb/ jzwatch/ platform-test-app/ testteam/, noneunknown/. Renovate PR runs in cupcake and frosting succeed: same-repo bot branches have OIDC. So the skip only triggers when the run really has no token.🤖 Generated with Claude Code