Skip to content

Commit df93b9d

Browse files
committed
fix(ci): prevent duplicate label events on Dependabot PRs
Dependabot's built-in label config fires duplicate API calls due to a race condition, emitting two "labeled" webhook events. Move labeling to a GitHub Action that checks existing labels before adding, ensuring a single clean event.
1 parent fbd1935 commit df93b9d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ updates:
99
directory: '/' # Location of package manifests
1010
schedule:
1111
interval: 'weekly'
12-
labels:
13-
- 'USER STORY'
1412
ignore:
1513
# As a library, we intentionally avoid updating TypeScript and @types/node so that we
1614
# don't accidentally use features from a version newer than our downstream users have installed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Label Dependabot PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
label:
9+
if: github.actor == 'dependabot[bot]'
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write
13+
steps:
14+
- name: Add label if missing
15+
uses: actions/github-script@v7
16+
with:
17+
script: |
18+
const label = 'USER STORY';
19+
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
issue_number: context.issue.number,
23+
});
24+
if (!labels.some(l => l.name === label)) {
25+
await github.rest.issues.addLabels({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
issue_number: context.issue.number,
29+
labels: [label],
30+
});
31+
}

0 commit comments

Comments
 (0)