Skip to content

Commit 4f8f330

Browse files
authored
pull_request_target?
1 parent 2d20ff3 commit 4f8f330

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

.github/workflows/Label.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
name: Label breaking changes for semantic versioning
22

3-
on: [pull_request]
3+
on: [pull_request_target] # run on the merge target branch instead of the merge commit to grant pull-requests:write permission
44
jobs:
55
Label:
66
runs-on: windows-latest
77
permissions:
88
pull-requests: write # allow adding a label to this pull request
99
steps:
1010
- uses: actions/checkout@v6
11-
with:
12-
submodules: recursive
13-
fetch-depth: 0 # fetch all commit history across all branches and tags, instead of only one commit by default
1411
- name: If there are changes in PublicApi.Shipped.txt, fail the workflow
1512
if: github.head_ref != 'action/ship-publicapi' # Same branch name specified in Release.yml
1613
run: |
17-
$changes = git diff --numstat --shortstat origin/${{ github.base_ref }}...${{ github.sha }} -- '**/PublicApi.Shipped.txt'
14+
$head = git rev-parse HEAD
15+
Write-Output "HEAD is $head"
16+
$changes = git diff --numstat --shortstat HEAD..${{ github.sha }} -- '**/PublicApi.Shipped.txt'
1817
Write-Output "$changes"
1918
if ($changes) {
2019
Write-Error "Changes detected in PublicApi.Shipped.txt files. Public API changes must be shipped through the release process, not in regular pull requests."
@@ -29,7 +28,7 @@ jobs:
2928
Write-Output "This is a ship-publicapi PR, labeling as Type/Maintenance"
3029
} else {
3130
# For regular PRs, check for API changes
32-
$changes = git diff origin/${{ github.base_ref }}...${{ github.sha }} -- '**/PublicApi.Unshipped.txt'
31+
$changes = git diff HEAD..${{ github.sha }} -- '**/PublicApi.Unshipped.txt'
3332
Write-Output "$changes"
3433
3534
if ($changes) {

0 commit comments

Comments
 (0)