Skip to content

ci: stop label-gated workflows from re-triggering on every subsequent label#509

Merged
ocots merged 1 commit into
mainfrom
fix/ci-labeled-double-trigger
Jul 25, 2026
Merged

ci: stop label-gated workflows from re-triggering on every subsequent label#509
ocots merged 1 commit into
mainfrom
fix/ci-labeled-double-trigger

Conversation

@ocots

@ocots ocots commented Jul 25, 2026

Copy link
Copy Markdown
Member

Root cause

GitHub fires a separate pull_request event of type labeled for each label added individually, and the job's if condition is re-evaluated against the PR's current full label set every time — not just the label that triggered this specific event.

So if a PR gets labels run ci, then run documentation, then run breakage added one after another, the CI job (already matched by the first label) gets needlessly re-run again on the second and third label-add events too, since its label is still present in the full set. This wastes CI runs and confuses people watching the Actions tab.

Same root cause and fix as control-toolbox/CTFlows.jl's recent CI.yml fix.

Fix

For the labeled event specifically, check github.event.label.name against the job's own gating label; for every other trigger type (synchronize/reopened), keep the existing full-label-set check unchanged.

Files changed

  • .github/workflows/CI.ymlcall job, label run ci
  • .github/workflows/Documentation.ymlcall job, label run documentation
  • .github/workflows/Breakage.ymlcall job, label run breakage

All other workflow files under .github/workflows/ (AddToProject, AutoAssign, CompatHelper, Coverage, Formatter, SpellCheck, TagBot, UpdateReadme) were checked via grep -rl "labeled" .github/workflows/ and do not use this pattern, so they were left untouched.

Validation

All three edited YAML files parse correctly via python3 -c "import yaml; ...".

🤖 Generated with Claude Code

… label

GitHub fires a separate pull_request 'labeled' event per label added, and
re-evaluates each job's `if` condition against the PR's *current* full label
set, not just the label that triggered this specific event. So adding several
run-gating labels to a PR one after another re-runs every already-matching
job on each subsequent label add, not just the newly-matched one.

Fixed by checking github.event.label.name for 'labeled' events specifically,
falling back to the existing full-label-set check for every other trigger
type. Applied to: .github/workflows/CI.yml ('call' job, label 'run ci'),
.github/workflows/Documentation.yml ('call' job, label 'run documentation'),
.github/workflows/Breakage.yml ('call' job, label 'run breakage').

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ocots
ocots merged commit 21b4ba6 into main Jul 25, 2026
3 checks passed
@ocots
ocots deleted the fix/ci-labeled-double-trigger branch July 25, 2026 10:36
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.

1 participant