fix(ci): fix guard condition and add auto-merge to bump-sha#165
Conversation
Two fixes: 1. Guard condition: The 'Manage PRs' step only checked steps.push-branch.outputs.skip, but when the guard skips all steps, push-branch never runs and its outputs are empty — causing the step to execute with empty env vars and fail. Add steps.guard.outputs.skip check to prevent this. 2. Auto-merge: After creating the bump PR, enable auto-merge with gh pr merge --auto --squash so the PR self-merges once required checks pass. The bump commit only touches manifest.yml and was already tested by the triggering workflow.
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 25 minutes and 57 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 (1)
✨ 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 |
|
|
|
||
| - name: Manage PRs — close old, clean orphans, open new | ||
| if: steps.push-branch.outputs.skip != 'true' | ||
| if: steps.guard.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true' |
There was a problem hiding this comment.
Incomplete guard condition —
check skip case still unprotected
The PR fixes the guard skip case, but the condition still doesn't include steps.check.outputs.skip != 'true'. When check determines the SHA is already at HEAD (or the manifest entry is missing), it sets skip=true and exits early, causing push-branch to be skipped entirely. A skipped step outputs an empty string for all its outputs, so steps.push-branch.outputs.skip becomes '' — and '' != 'true' is true — meaning Manage PRs still executes with BRANCH="", NEW_SHA="", and OLD_SHA="". Under set -euo pipefail, the select(.headRefName != "") filter matches every existing bump PR and closes them all, and the orphan-cleanup loop deletes every bump branch — damaging valid open PRs.
| if: steps.guard.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true' | |
| if: steps.guard.outputs.skip != 'true' && steps.check.outputs.skip != 'true' && steps.push-branch.outputs.skip != 'true' |



两个问题
问题 1:Guard 跳过后续步骤后,Manage PRs 步骤仍然执行导致失败
原因:
Manage PRs步骤的条件只检查了steps.push-branch.outputs.skip != 'true'。当 Guard 检测到 bump commit 并设置
skip=true后,push-branch步骤不会执行,其 outputs 为空字符串,
"" != 'true'为 true,导致步骤以空的 env vars 执行而失败。修复:在条件中加入
steps.guard.outputs.skip != 'true':问题 2:Bump PR 创建后没有自动合并
原因:Workflow 只创建了 PR,没有自动合并逻辑。
修复:PR 创建后执行
gh pr merge --auto --squash,启用 auto-merge。Bump commit 只修改
manifest.yml,且已在触发 workflow 的合并中测试过,自动合并可以避免手动干预,同时遵守 branch protection 规则。
no-issue
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Greptile Summary
This PR fixes two issues in the
on-main-bump-shaworkflow: a guard condition bug whereManage PRswould run with empty env vars when the Guard step triggered a skip, and the absence of auto-merge logic for the bump PR. The guard fix and auto-merge addition are both correct in intent, but the condition update is incomplete.Manage PRscondition now checkssteps.guard.outputs.skip, correctly fixing the described bug, but it still omitssteps.check.outputs.skip != 'true'. Whencheckdecides the SHA is already at HEAD,push-branchis skipped and itsskipoutput becomes an empty string (not'true'), soManage PRsstill executes with emptyBRANCH,NEW_SHA, andOLD_SHA— potentially closing all existing bump PRs and deleting all bump branches unintentionally.gh pr merge --auto --squashwith a graceful|| warningfallback, and the commit subject matches the guard's detection pattern so re-entrancy is correctly prevented.Confidence Score: 3/5
The guard fix addresses the stated bug, but leaves an adjacent hole that can cause the Manage PRs step to run with empty variables, closing or deleting valid open bump PRs on every SHA-is-current run.
The condition on the
Manage PRsstep still lacks asteps.check.outputs.skipguard. Whenever the SHA is already at HEAD (a normal, recurring state),checkoutputsskip=true,push-branchis skipped, and its outputs are empty strings — making the remaining two guards insufficient. The step then runs against emptyBRANCH,OLD_SHA, andNEW_SHA, and the JQ filterselect(.headRefName != "")matches every existing bump PR, closing them all and deleting their branches..github/workflows/on-main-bump-sha.yml — specifically the
Manage PRsstep condition at line 159.Important Files Changed
Manage PRscondition still lacks asteps.check.outputs.skip != 'true'guard; the auto-merge logic is otherwise well-structured with graceful fallback.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Push to main] --> B[Guard step] B -- skip=true\nbump commit detected --> Z[End — skip all] B -- skip=false --> C[Check step\nSHA stale?] C -- skip=true\nSHA already at HEAD --> D{Manage PRs condition} C -- skip=false --> E[Run bump-self-sha.sh] E --> F[Push branch\nid: push-branch] F -- skip=true\nno files changed --> D F -- skip=false\nbranch pushed --> D D -- guard=false AND check=false AND push-branch.skip=false --> G[Manage PRs] D -- any skip=true --> Z2[End — skip] G --> H[gh pr create / reuse existing] H --> I[gh pr merge --auto --squash] I -- success --> J[Auto-merge enabled] I -- failure --> K[warning: repo may lack Allow auto-merge]Reviews (1): Last reviewed commit: "fix(ci): fix guard condition and add aut..." | Re-trigger Greptile