Skip to content

fix(ci): prevent edited events from creating skipped CI runs#13170

Merged
DeJeune merged 2 commits intomainfrom
fix/ci-edited-event-skip
Mar 4, 2026
Merged

fix(ci): prevent edited events from creating skipped CI runs#13170
DeJeune merged 2 commits intomainfrom
fix/ci-edited-event-skip

Conversation

@EurFelux
Copy link
Copy Markdown
Collaborator

@EurFelux EurFelux commented Mar 3, 2026

What this PR does

Before this PR:
Editing a PR's title or body triggers the edited event in the CI workflow. Although job-level if conditions skip execution, GitHub still creates a new workflow run with "skipped" status. Since GitHub UI shows the latest run, this hides the real CI results from the previous opened/synchronize run.

After this PR:

  • Removed edited from CI workflow trigger types, so title/body edits no longer create skipped CI runs
  • Added a lightweight separate workflow (ci-rerun-on-base-change.yml) that listens for edited events and re-runs the latest CI run only when the PR's base branch is changed

Fixes #13150 (follow-up)

Why we need it and why it was done in this way

The following tradeoffs were made:

  • Splitting into two workflows is slightly more complex than a single workflow, but it completely eliminates the "skipped run covering real results" problem since the re-run workflow has a different workflow name and does not affect the main CI status display

The following alternatives were considered:

Breaking changes

None

Special notes for your reviewer

  • The re-run workflow uses actions/github-script to call reRunWorkflow API, which re-runs the existing CI run in-place rather than creating a new one
  • The workflow requires actions: write permission to trigger re-runs
  • The branches list in the new workflow mirrors the main CI workflow to stay in sync

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: A user-guide update was considered and is present (link) or not required.
  • Self-review: I have reviewed my own code before requesting review from others

Release note

NONE

- Create new workflow that triggers when PR base branch is edited
- Remove `edited` trigger from main CI workflow to avoid duplicate runs
- Simplify CI workflow conditions by removing base change check
GeorgeDong32

This comment was marked as duplicate.

Copy link
Copy Markdown
Collaborator

@GeorgeDong32 GeorgeDong32 left a comment

Choose a reason for hiding this comment

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

LGTM with one minor suggestion:

Suggested improvement: Consider adding status: 'completed' to the listWorkflowRuns API call to avoid re-running in-progress workflows:

const runs = await github.rest.actions.listWorkflowRuns({
  workflow_id: 'ci.yml',
  head_sha: context.payload.pull_request.head.sha,
  per_page: 1,
  status: 'completed',  // Only get completed runs
});

This ensures the re-run only targets completed CI runs, preventing potential race conditions if the CI is still running when the base branch is changed.

Otherwise, the PR looks great - clean separation of concerns and proper use of the GitHub Actions API.

Copy link
Copy Markdown
Collaborator

@DeJeune DeJeune left a comment

Choose a reason for hiding this comment

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

Well-designed fix with clean separation of concerns. Splitting the edited event into its own lightweight workflow solves the "skipped run hiding real CI results" problem elegantly — different workflow names never interfere with each other in the GitHub UI.

Significant:

  • reRunWorkflow API returns 409 if the target run is still in-progress/queued. Consider adding a status check or try/catch to handle this gracefully.

Nit:

  • Top-level permissions could be scoped to job-level for precision (minor, single-job workflow).

Positives:

  • Clean architectural split that avoids masking real CI status
  • Simplified if conditions in ci.yml — much more readable
  • Excellent PR description with clear tradeoff analysis

per_page: 1,
});
if (runs.data.workflow_runs.length > 0) {
await github.rest.actions.reRunWorkflow({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Significant: reRunWorkflow will fail if the previous run is still in_progress or queued (API returns 409 Conflict). This can happen if someone changes the base branch while CI is still running from a recent push.

Consider either:

  1. Checking the run's status before re-running and cancelling it first if needed
  2. Wrapping in a try/catch with a helpful log message so it doesn't show as a workflow failure
const run = runs.data.workflow_runs[0];
if (run.status === 'completed') {
  await github.rest.actions.reRunWorkflow({...});
} else {
  console.log(`CI run ${run.id} is still ${run.status}, skipping re-run`);
}

Comment on lines +1 to +3
name: Re-run CI on base branch change

permissions:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: Top-level permissions here grants actions: write to the entire workflow. This is fine for now since there's only one job, but worth noting that any future jobs added to this file would inherit this permission. A job-level permissions block would be more precise.

Address review feedback: only re-run completed CI runs to avoid 409
conflicts, and move permissions to job level for better scoping.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@EurFelux EurFelux requested a review from DeJeune March 4, 2026 10:24
@DeJeune DeJeune merged commit c66ecee into main Mar 4, 2026
15 checks passed
@DeJeune DeJeune deleted the fix/ci-edited-event-skip branch March 4, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants