Skip to content

Commit 3106907

Browse files
authored
fix(workflow): separate release-drafter and autolabeler workflows for v7 compatibility (#366)
- Split release-drafter.yml: triggers only on push to main, uses release-drafter@v7 - Create release-drafter-autolabeler.yml: triggers on pull_request + pull_request_target with fork-aware gating to handle same-repo and fork PRs without duplicate runs - Update permissions: drafter needs contents:write, autolabeler needs pull-requests:write - Fix commitish: use explicit 'main' instead of dynamic repository.default_branch - Autolabeler now uses correct release-drafter/release-drafter/autolabeler@v7 action Fixes PRs not getting auto-labeled after v7 migration
1 parent f0d9e3d commit 3106907

2 files changed

Lines changed: 35 additions & 7 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release Drafter Autolabeler
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
pull_request_target:
7+
types: [opened, reopened, synchronize]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
autolabel-pr:
14+
if: >-
15+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
16+
||
17+
(github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository)
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/create-github-app-token@v3
24+
id: app-token
25+
with:
26+
client-id: ${{ secrets.APP_ID }}
27+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
28+
- uses: release-drafter/release-drafter/autolabeler@v7
29+
with:
30+
config-name: release-drafter-config.yml
31+
env:
32+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

.github/workflows/release-drafter.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ name: Release Drafter
33
on:
44
push:
55
branches:
6-
- dev
7-
pull_request:
8-
# Only following types are handled by the action, but one can default to all as well
9-
types: [opened, reopened, synchronize]
6+
- main
107

118
permissions:
129
contents: read
@@ -16,8 +13,7 @@ jobs:
1613
permissions:
1714
# write permission is required to create a github release
1815
contents: write
19-
# write permission is required for autolabeler
20-
pull-requests: write
16+
pull-requests: read
2117
runs-on: ubuntu-latest
2218
steps:
2319
- uses: actions/create-github-app-token@v3
@@ -28,7 +24,7 @@ jobs:
2824
- uses: release-drafter/release-drafter@v7
2925
with:
3026
config-name: release-drafter-config.yml
31-
commitish: ${{ github.event.repository.default_branch }}
27+
commitish: main
3228
publish: false
3329
env:
3430
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)