ci: auto-bump platform submodule on merge to main#394
Conversation
FailproofAI/platform vendors this repo as a git submodule at failproofai/oss and currently has to bump the pinned commit by hand. This workflow makes the bump push-driven: on every push to main here, check out platform/main with a PAT (PLATFORM_BUMP_TOKEN, scoped contents:read+write on the platform repo), rewrite the gitlink for failproofai/oss to github.sha via update-index --cacheinfo (no need to fetch submodule contents), commit, and push. Concurrency group serializes back-to-back merges so we never lose a bump, and a rebase-and-retry loop keeps us race-safe if a human pushes to platform main between checkout and push. Same shape works on manual workflow_dispatch.
📝 WalkthroughWalkthroughAdds a GitHub Actions workflow that, on pushes to ChangesAutomated submodule bump workflow
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/bump-platform-submodule.yml:
- Around line 23-30: The checkout step currently uses actions/checkout@v6
without pinning to a commit SHA and leaves credential persistence enabled;
update the step that references "uses: actions/checkout@v6" to pin the action to
a specific commit SHA (replace `@v6` with the full SHA for the release you want)
and add the input "persist-credentials: false" alongside the existing inputs
(token, ref, fetch-depth, submodules) so the cross-repo token is not written to
git config.
In `@CHANGELOG.md`:
- Line 6: The CHANGELOG entry for the bump-platform-submodule workflow is
missing the PR number; update the single-line entry describing the
`bump-platform-submodule.yml` workflow (the line that mentions
`PLATFORM_BUMP_TOKEN`, `failproofai/oss` gitlink bump and `FailproofAI/platform`
main) to append the PR reference in the format `(#<PR_NUMBER>)` so the line
becomes one sentence followed by the PR number per repo convention.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3426775a-dcae-4b49-b0a1-c0cb1c263e7c
📒 Files selected for processing (2)
.github/workflows/bump-platform-submodule.ymlCHANGELOG.md
Pin actions/checkout to v6.0.1 SHA (matching osv-scanner.yml) and set persist-credentials: false so the cross-repo PAT isn't written to git config; auth the push/fetch in the retry loop inline via http.extraheader. Adds #394 to the CHANGELOG entry. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Actionable comments posted: 0 |
The persist-credentials: false hardening from #394 broke the first post-merge run with: fatal: could not read Username for 'https://github.com' The inline http.extraheader was using "Authorization: bearer <pat>", which authenticates GitHub's REST API but not git-over-HTTPS smart protocol — git push/fetch want Basic auth with `x-access-token:<pat>` (what actions/checkout itself sets internally when persist-credentials is true). Swap to the base64-encoded Basic header so both the push and the fetch in the rebase-and-retry loop authenticate. Co-authored-by: Nikita Agarwal <niki.darj@gmail.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Adds
.github/workflows/bump-platform-submodule.yml. On every push tomainin this repo, it pushes a matchingfailproofai/ossgitlink bump toFailproofAI/platformmain, so the monorepo's pinned submodule commit tracks upstream automatically. No PR in platform — direct push of a one-line gitlink update.How it works
pushtomain(andworkflow_dispatchfor manual re-syncs).FailproofAI/platformmainwith a PAT (PLATFORM_BUMP_TOKEN).failproofai/ossviagit update-index --cacheinfo 160000,<sha>,failproofai/oss— no need to clone submodule contents.github-actions[bot]with the upstream commit subject in the body, then pushes.concurrency: bump-platform-submoduleserializes back-to-back merges so we never lose a bump.mainbetween checkout and push.actions/checkoutto a commit SHA (v6.0.1, matchingosv-scanner.yml) and setspersist-credentials: falseso the cross-repo PAT isn't written into git config; the push/fetch in the retry loop authenticate inline viahttp.extraheader.🚨 Required setup before this merges
This won't actually work until one repo secret exists and one PAT is provisioned. Do these in order.
1. Create a fine-grained Personal Access Token
GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token
FailproofAIFailproofAI/platformContents: Read and write (required — needed to push the bump commit)Metadata: Read-only (auto-selected)Copy the token — you only see it once.
2. Add the token as a repo secret on this repo
FailproofAI/failproofai→ Settings → Secrets and variables → Actions → New repository secretPLATFORM_BUMP_TOKEN(must match exactly — the workflow references this name)3. (If applicable) Allow the bot to push to platform
mainIf
FailproofAI/platformhas branch protection onmainthat requires PRs or status checks, direct push from this workflow will fail. Pick one:mainbranch protection rule.peter-evans/create-pull-request). Happy to follow up with that variant if preferred — just say the word.If
mainhas no protection, no action needed.4. Smoke-test after merge
Once this PR merges:
Bump platform submodule pointerrun.FailproofAI/platform,git log --oneline main -3should show a freshBump failproofai/oss to <short-sha>commit bygithub-actions[bot].main.Test plan
Contents: read & writeonFailproofAI/platformPLATFORM_BUMP_TOKENsecret added to this repomainbranch protection allows the PAT owner to push (or N/A)mainworkflow_dispatchfrom the Actions tab also succeeds and is a no-op when already in syncSummary by CodeRabbit
Chores
Documentation