Skip to content

ci: auto-rebase open PRs on main push - #313

Merged
yoshi280 merged 3 commits into
mainfrom
ci/auto-rebase-open-prs
Apr 30, 2026
Merged

ci: auto-rebase open PRs on main push#313
yoshi280 merged 3 commits into
mainfrom
ci/auto-rebase-open-prs

Conversation

@robotrocketscience

@robotrocketscience robotrocketscience commented Apr 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • New workflow .github/workflows/auto-rebase-open-prs.yml fires on push to main and on workflow_dispatch.
  • For each open PR with base=main, fetches the head branch, attempts git rebase origin/main, force-pushes if clean.
  • Conflicts get a merge-conflict label and a comment with the local-recovery one-liner.

Why

Three concurrent sessions opening PRs against main means every merge invalidates ~2 in-flight PRs. Reviewer hits "BLOCKED — needs rebase" and bounces. This eliminates the manual rebase step for the common (clean) case and makes real conflicts surface as a flag.

Resolves

Refs #256 review thrash (5+ claim/release cycles before merge).

Test plan

  • Merge this PR. Watch the next merge-to-main; verify any other open PRs auto-rebase.
  • Land a deliberately conflicting branch; verify it gets the merge-conflict label + comment.

Summary by Sourcery

CI:

  • Add a GitHub Actions workflow that rebases all open PRs targeting main onto the updated main branch, force-pushes clean rebases, and labels/comment flags PRs with merge conflicts.

Summary by CodeRabbit

  • Chores
    • Adds automated rebasing of open PRs onto main to keep branches up to date; skips PRs already current.
    • When rebasing succeeds, updates branches automatically; when conflicts occur, labels PRs as "merge-conflict" and posts guidance on how to resolve and update the PR.

@sourcery-ai

sourcery-ai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a GitHub Actions workflow that automatically rebases all open PR branches targeting main whenever main is updated or the workflow is manually triggered, force-pushing clean rebases and labeling/commenting on PRs that encounter conflicts.

Sequence diagram for auto-rebase of a single PR on main push

sequenceDiagram
  participant GitHub
  participant Workflow as auto-rebase-open-prs
  participant gh as gh_CLI
  participant Git as Git_local
  participant API as GitHub_API
  participant PR as Pull_Request

  GitHub->>Workflow: Trigger on push to main
  Workflow->>Git: actions/checkout with full history
  Workflow->>Git: Configure bot user

  Workflow->>gh: gh pr list --state open --base main
  gh->>API: List open PRs base=main
  API-->>gh: PR list (number, headRefName)
  gh-->>Workflow: Encoded PR data

  loop For each PR
    Workflow->>Git: git fetch origin head
    alt fetch succeeds
      Workflow->>Git: git checkout -B head origin/head
      Workflow->>Git: git merge-base --is-ancestor origin/main HEAD
      alt Already on top of main
        Git-->>Workflow: is-ancestor true
        Workflow->>Workflow: Skip rebase
      else Behind main
        Git-->>Workflow: is-ancestor false
        Workflow->>Git: git rebase origin/main
        alt Rebase clean
          Git-->>Workflow: Rebase success
          Workflow->>Git: git push --force-with-lease origin head
          alt Push succeeds
            Git-->>Workflow: Push success
            Workflow->>gh: gh pr edit --remove-label merge-conflict
            gh->>API: Remove merge-conflict label
            API-->>gh: Label updated
          else Push rejected
            Git-->>Workflow: Push rejected
            Workflow->>Git: git rebase --abort
          end
        else Rebase has conflicts
          Git-->>Workflow: Rebase conflict
          Workflow->>Git: git rebase --abort
          Workflow->>gh: gh pr edit --add-label merge-conflict
          gh->>API: Add merge-conflict label
          API-->>gh: Label added
          Workflow->>gh: gh pr comment with recovery instructions
          gh->>API: Create PR comment
          API-->>gh: Comment created
        end
      end
    else fetch fails
      Git-->>Workflow: Fetch error
      Workflow->>Workflow: Skip this PR
    end
  end

  Note over PR,Workflow: PR ends either updated on main or flagged with merge-conflict
Loading

File-Level Changes

Change Details Files
Introduce a GitHub Actions workflow to auto-rebase open PRs targeting main and handle conflicts with labels and comments.
  • Add workflow triggered on pushes to main and manual dispatch with write permissions to contents and pull requests.
  • Use gh CLI to list open PRs with base=main and iterate over their head branches.
  • For each PR, fetch and check out the head branch, skip if already based on current main, otherwise attempt git rebase origin/main.
  • On successful rebase, force-push the branch and remove any existing merge-conflict label, handling push races gracefully.
  • On rebase conflicts, abort the rebase, apply a merge-conflict label, and post a comment including a one-liner for local conflict resolution and force-push.
.github/workflows/auto-rebase-open-prs.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robotrocketscience has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 48 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 30f67f04-1920-421b-ad8f-f91c35327263

📥 Commits

Reviewing files that changed from the base of the PR and between 9e864b6 and 03e3978.

📒 Files selected for processing (1)
  • .github/workflows/auto-rebase-open-prs.yml
📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow that lists open PRs targeting main, fetches each PR head, checks ancestry against origin/main, rebases branches when needed, force-pushes successful rebases, and labels/posts a comment on rebase conflicts.

Changes

Cohort / File(s) Summary
Auto-rebase Workflow
.github/workflows/auto-rebase-open-prs.yml
New CI workflow that lists open PRs with base=main, fetches PR heads, checks git merge-base --is-ancestor against origin/main, attempts git rebase and git push --force-with-lease on success, aborts and adds merge-conflict label plus a comment with resolution commands on conflict, and handles push failures gracefully.

Sequence Diagram(s)

sequenceDiagram
  participant Scheduler as GitHub Actions
  participant GH_API as GitHub API
  participant Runner as Workflow Runner (git)
  participant Remote as origin/main

  Scheduler->>GH_API: List open PRs (base=main)
  loop per PR
    GH_API->>Runner: Fetch PR head branch
    Runner->>Remote: fetch origin/main
    Runner->>Runner: git merge-base --is-ancestor?
    alt up-to-date
      Runner->>GH_API: no-op / skip
    else needs rebase
      Runner->>Runner: git rebase origin/main
      alt rebase success
        Runner->>Remote: git push --force-with-lease
        alt push success
          Runner->>GH_API: remove merge-conflict label (if present)
        else push failed
          Runner->>Runner: git rebase --abort
          Runner->>GH_API: leave PR for future retry
        end
      else rebase conflict
        Runner->>Runner: git rebase --abort
        Runner->>GH_API: add merge-conflict label
        Runner->>GH_API: post comment with manual rebase commands
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: introducing a GitHub Actions workflow that automatically rebases open PRs when main is updated.
Description check ✅ Passed The description covers Summary, Why (motivation), Linked issues (via Refs), Test plan, and includes Sourcery summary. However, it lacks explicit Type of change checkbox selection and Verification section checkboxes required by the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/auto-rebase-open-prs

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 56 minutes and 48 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@robotrocketscience robotrocketscience added the author-Kulili PR coordination mutex label Apr 29, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider explicitly skipping PRs from forks (e.g., by querying headRepositoryOwner and comparing to the main repo) so the workflow doesn’t repeatedly log fetch failures for branches that aren’t available on the origin remote.
  • To avoid noisy duplicate comments on long-lived conflicted PRs, you might gate the merge-conflict comment on whether the label was just added or whether a previous bot comment already exists.
  • It may be worth adding a concurrency group to this workflow so that only the latest run for main is active, preventing overlapping jobs from fighting over rebases and force-pushes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider explicitly skipping PRs from forks (e.g., by querying `headRepositoryOwner` and comparing to the main repo) so the workflow doesn’t repeatedly log fetch failures for branches that aren’t available on the `origin` remote.
- To avoid noisy duplicate comments on long-lived conflicted PRs, you might gate the `merge-conflict` comment on whether the label was just added or whether a previous bot comment already exists.
- It may be worth adding a `concurrency` group to this workflow so that only the latest run for `main` is active, preventing overlapping jobs from fighting over rebases and force-pushes.

## Individual Comments

### Comment 1
<location path=".github/workflows/auto-rebase-open-prs.yml" line_range="39-40" />
<code_context>
+        run: |
+          set -e
+          # JSON: [{number, headRefName, baseRefName}]
+          prs=$(gh pr list --state open --base main \
+                  --json number,headRefName,baseRefName \
+                  --jq '.[] | @base64')
+
</code_context>
<issue_to_address>
**question (bug_risk):** This will silently skip PRs from forks, which may or may not match the intended behavior.

`git fetch origin "$head"` will always fail for fork-based PRs, so they’ll always take the "fetch failed, skip" path and never be auto-rebased, even though `gh pr list` includes them. If you only want same-repo PRs, filter them explicitly in the `gh pr list` JSON (e.g., via `headRepositoryOwner`/`headRepository`). If you do want to support forks, you’ll need a different approach than force-pushing to `origin/$head`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
@robotrocketscience

Copy link
Copy Markdown
Owner Author

[claim:review:Setr:2026-04-29T16:24:08Z]

@robotrocketscience

Copy link
Copy Markdown
Owner Author

Review: discretion grep on the diff catches one banned phrase in .github/workflows/auto-rebase-open-prs.yml line 6:

# This is the "auto-fresh" half of the parallel-session workflow. The other

parallel-session / parallel session is on the banned-vocab list for public artifacts. Suggested rewrite:

# This is the "auto-fresh" half of the multi-author PR workflow. The other

Or just drop the sentence — the file purpose is already explained in the lines above. Otherwise the workflow logic looks correct (rebase, force-with-lease, conflict-flag with recovery one-liner). Sourcery + pattern-scan + history-scan + pytest all green.

Holding merge until the line is reworded. Will pick this back up once it lands.

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[release:review:Setr:2026-04-29T16:25:07Z]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/auto-rebase-open-prs.yml:
- Line 23: Replace the floating tag actions/checkout@v4 with a pinned commit SHA
by changing actions/checkout@v4 to actions/checkout@<COMMIT_SHA> (use the full
40-char commit from the actions/checkout repo for the v4 release) and keep the
human-readable tag in a trailing comment, e.g. actions/checkout@<COMMIT_SHA> #
v4, so the workflow is pinned while still showing the version.
- Around line 39-41: The PR listing command stored in the prs variable uses gh
pr list which defaults to 30 results; update the gh pr list invocation (the
command assigned to prs) to explicitly request all PRs by adding the --limit 0
flag (e.g., change "gh pr list --state open --base main --json ..." to "gh pr
list --limit 0 --state open --base main --json ...") so the workflow processes
every open PR rather than the default paginated 30.
- Around line 69-75: Replace the double-quoted inline body passed to gh pr
comment (the block that contains the escaped backticks and $head) with a heredoc
to avoid YAML/quote escaping, and make the branch checkout safe by quoting the
variable (use git checkout "$head" or compute safe_head="$(printf '%q' "$head")"
and use that). Specifically, change the gh pr comment invocation to use a
here-doc (gh pr comment "$num" --body <<EOF ... EOF) containing the
triple-backtick fenced block and use git checkout "$head" (or "$safe_head")
inside it so branch names with spaces/special chars are handled correctly.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2bedaba2-afac-4140-a352-37b5fa972af9

📥 Commits

Reviewing files that changed from the base of the PR and between 2a8f47f and 4857c0a.

📒 Files selected for processing (1)
  • .github/workflows/auto-rebase-open-prs.yml

Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
@robotrocketscience

Copy link
Copy Markdown
Owner Author

Reworded line 6 — parallel-sessionmulti-author PR. Pushed as 3ca9ffc. Ready for re-review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (3)
.github/workflows/auto-rebase-open-prs.yml (3)

23-23: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin actions/checkout to an immutable SHA.

Line 23 is still using a floating tag (@v4), which violates the workflow supply-chain pinning rule.

Suggested fix
-      - uses: actions/checkout@v4
+      - uses: actions/checkout@<FULL_40_CHAR_SHA> # v4.x.x

As per coding guidelines, "Third-party actions must be pinned to a commit SHA, with the version tag in a trailing comment. Flag any unpinned @v* ref."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/auto-rebase-open-prs.yml at line 23, Replace the floating
actions/checkout@v4 reference with a pinned commit SHA: update the uses entry
that currently reads "uses: actions/checkout@v4" to use the specific immutable
SHA for the desired v4 release (e.g., "uses: actions/checkout@<COMMIT_SHA>") and
include the original tag as a trailing comment (e.g., "# v4") so the tag is
recorded but the workflow is pinned; ensure this change is applied where "uses:
actions/checkout@v4" appears.

69-75: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix invalid YAML in conflict comment body (workflow currently won’t parse).

Lines 69-75 use escaped triple backticks inside a double-quoted YAML string, which is invalid YAML syntax and breaks the workflow.

Suggested fix
-                  gh pr comment "$num" --body \
-"Auto-rebase onto main failed: conflicts. Resolve locally:
-\`\`\`
-git fetch origin && git checkout $head && git rebase origin/main
-# resolve, then
-git push --force-with-lease
-\`\`\`" 2>/dev/null || true
+                  gh pr comment "$num" --body-file - <<EOF 2>/dev/null || true
+Auto-rebase onto main failed: conflicts. Resolve locally:
+```
+git fetch origin && git checkout "$head" && git rebase origin/main
+# resolve, then
+git push --force-with-lease
+```
+EOF
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/auto-rebase-open-prs.yml around lines 69 - 75, The
workflow comment currently embeds escaped triple backticks inside a
double-quoted YAML string causing invalid YAML; update the gh pr comment
invocation (the command that calls gh pr comment "$num" --body) to use a
YAML-safe multiline string (here-doc / EOF or block scalar) for the --body so
the backtick fence is not escaped, include the branch variable quoted (use
"$head") inside the here-doc, end the here-doc after the final backtick fence,
and ensure the entire gh pr comment command redirects errors as before
(2>/dev/null || true) so the job parses and preserves the intended message with
a proper git fetch/checkout/rebase sequence and the fenced code block.

39-41: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Process all open PRs explicitly (avoid default gh pagination).

Line 39 uses gh pr list without --limit; default pagination can skip PRs beyond the first page, so rebases become incomplete.

Suggested fix
-          prs=$(gh pr list --state open --base main \
+          prs=$(gh pr list --state open --base main --limit 1000 \
                   --json number,headRefName,baseRefName \
                   --jq '.[] | `@base64`')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/auto-rebase-open-prs.yml around lines 39 - 41, The gh pr
list invocation stored in the prs variable can miss PRs due to default
pagination; update the command used to build prs (the prs=$(gh pr list --state
open --base main --json number,headRefName,baseRefName --jq '.[] | `@base64`')) to
include an explicit limit flag (e.g., add --limit 1000) so all open PRs are
returned and processed rather than only the first page.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/auto-rebase-open-prs.yml:
- Around line 39-50: The current loop that iterates over prs uses git fetch
origin "$head" and git checkout -B "$head" "origin/$head" which silently fails
for fork-based PRs; change the fetch/checkout to use GitHub's PR head ref
(refs/pull/<num>/head) for every PR number (num) so both fork and same-repo PRs
are fetched and checked out reliably; update the fetch invocation that uses
"$head" and the checkout invocation that references "origin/$head" to instead
fetch refs/pull/$num/head and create/checkout the local branch from that fetched
ref.

---

Duplicate comments:
In @.github/workflows/auto-rebase-open-prs.yml:
- Line 23: Replace the floating actions/checkout@v4 reference with a pinned
commit SHA: update the uses entry that currently reads "uses:
actions/checkout@v4" to use the specific immutable SHA for the desired v4
release (e.g., "uses: actions/checkout@<COMMIT_SHA>") and include the original
tag as a trailing comment (e.g., "# v4") so the tag is recorded but the workflow
is pinned; ensure this change is applied where "uses: actions/checkout@v4"
appears.
- Around line 69-75: The workflow comment currently embeds escaped triple
backticks inside a double-quoted YAML string causing invalid YAML; update the gh
pr comment invocation (the command that calls gh pr comment "$num" --body) to
use a YAML-safe multiline string (here-doc / EOF or block scalar) for the --body
so the backtick fence is not escaped, include the branch variable quoted (use
"$head") inside the here-doc, end the here-doc after the final backtick fence,
and ensure the entire gh pr comment command redirects errors as before
(2>/dev/null || true) so the job parses and preserves the intended message with
a proper git fetch/checkout/rebase sequence and the fenced code block.
- Around line 39-41: The gh pr list invocation stored in the prs variable can
miss PRs due to default pagination; update the command used to build prs (the
prs=$(gh pr list --state open --base main --json number,headRefName,baseRefName
--jq '.[] | `@base64`')) to include an explicit limit flag (e.g., add --limit
1000) so all open PRs are returned and processed rather than only the first
page.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8311fd42-a3aa-423b-a90a-4619848e479a

📥 Commits

Reviewing files that changed from the base of the PR and between 4857c0a and 3ca9ffc.

📒 Files selected for processing (1)
  • .github/workflows/auto-rebase-open-prs.yml

Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
Cuts cross-session rebase churn. Every push to main fetches each open PR
branch, attempts rebase onto origin/main, and force-pushes if clean.
Conflicts get a merge-conflict label + recovery comment so the author
sees them in the next aelf-scan section 3.
- Pin actions/checkout to commit SHA (v4.3.1) per supply-chain rule.
- Add concurrency group so overlapping main pushes don't fight on rebase/force-push.
- gh pr list --limit 1000 to disable default 30-PR pagination.
- Skip fork PRs explicitly (isCrossRepository) — GITHUB_TOKEN can't force-push to forks.
- Replace invalid double-quoted YAML body (escaped backticks) with mktemp + echo file, then --body-file.
- Gate conflict explainer comment on absence of merge-conflict label so long-lived conflicted PRs aren't spammed on every main push.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/auto-rebase-open-prs.yml:
- Around line 68-75: The current workflow always posts the conflict comment
regardless of prior state; change the logic so you only post the comment when a
PR transitions into conflicted state by checking labels first. Use gh pr view
"$num" --json labels (or inspect the output of gh pr edit "$num" --add-label
merge-conflict) to determine whether the merge-conflict label already exists for
"$num", and only run gh pr comment "$num" --body ... when the label was not
previously present (i.e., when you successfully added the merge-conflict label
or detected it as newly added); keep the existing label-add step (gh pr edit
"$num" --add-label merge-conflict) but gate the gh pr comment invocation on the
label being newly applied.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6824d05c-2d9d-474d-94a9-0b6feb174c47

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca9ffc and 9e864b6.

📒 Files selected for processing (1)
  • .github/workflows/auto-rebase-open-prs.yml

Comment thread .github/workflows/auto-rebase-open-prs.yml Outdated
@yoshi280

Copy link
Copy Markdown
Collaborator

[claim:review:Gylf:2026-04-30T09:14:26Z]

@yoshi280

Copy link
Copy Markdown
Collaborator

Concern before merge: force-pushes performed with secrets.GITHUB_TOKEN do not trigger downstream workflows. Per GitHub's documented behavior (docs), events triggered by the default GITHUB_TOKEN do not create a new workflow run, including pull_request: synchronize.

Effect: after this workflow rebases and force-pushes, the PR's required status checks (pytest, secrets-scan, pattern-scan, history-scan, etc.) stay pinned to the pre-rebase SHA. Reviewer sees "all green" on a commit that is no longer the PR head — the opposite of the "reviewer always sees an against-current-main diff [with current CI]" goal in the handoff.

Two fixes:

  1. Use a PAT (or GitHub App token) stored as a secret in place of GITHUB_TOKEN for the actions/checkout token + git push. PAT-driven pushes do trigger downstream workflows. Cost: a managed secret.
  2. After force-push, dispatch the CI workflow explicitly via gh workflow run against the PR head ref. Cost: needs CI to support workflow_dispatch with a ref input.

Option 1 is cleaner. Worth confirming locally — land a no-op rebase and check whether pull_request: synchronize runs on the head SHA or only on the original.

Otherwise the workflow looks correct: pinned action SHA, --force-with-lease, fork-PR skip, single-comment-per-conflict guard, ancestor-check skip for already-fresh branches.

@yoshi280

Copy link
Copy Markdown
Collaborator

[release:review:Gylf:2026-04-30T09:15:12Z]

@yoshi280

Copy link
Copy Markdown
Collaborator

[claim:review:Setr:2026-04-30T09:16:26Z]

@yoshi280

Copy link
Copy Markdown
Collaborator

Resolved CodeRabbit's fork-fetch thread: the workflow already skips fork PRs explicitly (isCrossRepository check) because GITHUB_TOKEN cannot force-push to fork heads regardless of fetch ref. Switching to refs/pull/N/head wouldn't change that. Same-repo PRs are the only ones we can rebase, and git fetch origin $head works correctly for those.

@yoshi280
yoshi280 merged commit 9148f66 into main Apr 30, 2026
10 checks passed
@yoshi280
yoshi280 deleted the ci/auto-rebase-open-prs branch April 30, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author-Kulili PR coordination mutex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants