fix(ci): revert workflow file changes before git-push in bump-sha#163
Conversation
github.token cannot push .github/workflows/ changes — the required 'workflows' permission scope doesn't exist in workflow syntax (only for GitHub Apps). After bump-self-sha.sh modifies all files containing the old SHA, we restore .github/workflows/ and only commit manifest.yml (and actions/). External repos rely on manifest.yml for the pinned SHA; stale internal workflow references are harmless since reusable workflows exist at old SHAs in repo history.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Warning Review limit reached
More reviews will be available in 39 minutes and 56 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
The diff correctly removes the inapplicable workflows: write permission and reverts workflow file changes before committing, since github.token cannot push to .github/workflows/. The test and documentation are updated consistently. One low-severity concern: bump-self-sha.sh still prints a stale git add command including .github/workflows/, which is misleading (though not executed by the workflow itself).



Problem
The
on-main-bump-shaworkflow cannot push changes to.github/workflows/files:github.tokenworkflowspermission"workflowsis not a valid permission scope in workflow syntax (only for GitHub Apps, not Actions workflows)Root Cause
github.tokencannot modify.github/workflows/files, period. The requiredworkflowspermission doesn't exist in the workflowpermissions:block.Fix
After
bump-self-sha.shmodifies all files containing the old SHA (including.github/workflows/*.yml), we restore workflow files withgit checkout -- .github/workflows/before committing. Onlymanifest.yml(and optionallyactions/) is pushed.This is safe because:
manifest.ymlfor the pinned SHA (viaresolve-openci)Files Changed
.github/workflows/on-main-bump-sha.yml— Addgit checkout -- .github/workflows/revert, update pathspectests/actions/workflow-integrity.bats— Update test for new revert patternno-issue
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Greptile Summary
This PR fixes the
on-main-bump-shaworkflow's inability to push.github/workflows/changes by reverting those changes before committing, sincegithub.tokencannot write to workflow files regardless of permissions.git checkout -- .github/workflows/immediately afterbump-self-sha.shruns, discarding workflow-file modifications before staging — this works becausebump-self-sha.shonly edits files in-place without staging.workflows: writepermission from the workflow'spermissions:block and updates thegit diff/git addpathspecs to exclude.github/workflows/.Confidence Score: 4/5
The change is safe to merge — it correctly addresses a real GitHub token limitation and the revert-before-stage approach is sound given bump-self-sha.sh never stages files itself.
The revert strategy is well-reasoned and works correctly because bump-self-sha.sh only modifies files in-place without staging, so git checkout -- .github/workflows/ cleanly undoes exactly the right set of changes. The Manage PRs step has a pre-existing condition edge case — when push-branch is skipped by the guard/check logic, steps.push-branch.outputs.skip is unset, so != 'true' evaluates true and Manage PRs could run with an empty $BRANCH variable — but this is unchanged by this PR.
No files require special attention; the workflow logic and the updated bats test are consistent with each other.
Important Files Changed
Sequence Diagram
sequenceDiagram participant W as on-main-bump-sha workflow participant S as bump-self-sha.sh participant FS as Working Tree participant G as git participant GH as GitHub (origin) W->>G: checkout (fetch-depth: 0) W->>W: guard step — skip if bot-authored commit W->>W: check step — compare manifest SHA vs HEAD W->>S: bash scripts/bump-self-sha.sh S->>FS: perl -pi -e (update manifest.yml) S->>FS: "perl -pi -e (update .github/workflows/*.yml)" S->>FS: "perl -pi -e (update actions/*.yml)" Note over S,FS: Files modified in-place, nothing staged W->>G: git checkout -- .github/workflows/ Note over G,FS: Revert workflow file changes (github.token cannot push them) W->>G: git diff --name-only HEAD -- manifest.yml actions/ alt no changes remain W-->>W: "skip=true, exit early" else manifest.yml / actions/ changed W->>G: git config user.name/email W->>G: "git checkout -b chore/bump-self-sha-{sha}" W->>G: git add manifest.yml actions/ W->>G: git commit W->>GH: "git push origin {branch}" W->>GH: gh pr create (or reuse existing) endReviews (1): Last reviewed commit: "fix(ci): revert workflow file changes be..." | Re-trigger Greptile