Skip to content

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

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#17
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 several run-gating labels added one after another (e.g. run ci, then run documentation, then run breakage), any job already matched by an earlier label gets needlessly re-run again on each subsequent label-add event, since its label is still present in the set. This wastes CI runs and confuses people watching the Actions tab.

Fix

For the labeled event specifically, check github.event.label.name against the job's own gating label (only that exact label re-triggers the job). For every other trigger type (synchronize/reopened/push), fall back to the existing full-label-set contains(...) check, unchanged.

Files touched

  • .github/workflows/CI.yml — job call, label run ci
  • .github/workflows/Documentation.yml — job call, label run documentation
  • .github/workflows/Breakage.yml — job call, label run breakage

These were the only workflow files matching the pattern (pull_request: types: [labeled, ...] combined with an if: using contains(github.event.pull_request.labels.*.name, ...)), confirmed via grep -rl "labeled" .github/workflows/. Other workflows (AutoAssign, CompatHelper, Coverage, Formatter, SpellCheck, TagBot, UpdateReadme) don't reference labeled at all and were left untouched.

All edited YAML files were validated with python3 -c "import yaml; ..." and parse correctly.

🤖 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: CI.yml (job `call`, label 'run ci'), Documentation.yml
(job `call`, label 'run documentation'), Breakage.yml (job `call`, label
'run breakage').

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ocots
ocots merged commit 0a1a356 into main Jul 25, 2026
2 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