Skip to content

Commit 5fa3866

Browse files
authored
Use base_ref and head_ref given commit history
1 parent 8451047 commit 5fa3866

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/Label.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ on: [pull_request]
44
jobs:
55
Label:
66
runs-on: windows-latest
7+
permissions:
8+
pull-requests: write # allow adding a label to this pull request
79
steps:
810
- uses: actions/checkout@v6
911
with:
1012
submodules: recursive
11-
fetch-depth: 0 # fetch all commit history across all branches and tags
13+
fetch-depth: 0 # fetch all commit history across all branches and tags, instead of only one commit by default
1214
- name: If there are changes in PublicApi.Shipped.txt, fail the workflow
1315
if: github.head_ref != 'action/ship-publicapi' # Same branch name specified in Release.yml
1416
run: |
15-
$changes = git diff --numstat --shortstat origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Shipped.txt'
17+
$changes = git diff --numstat --shortstat ${{ github.base_ref }}...${{ github.head_ref }} -- '**/PublicApi.Shipped.txt'
1618
Write-Output "$changes"
1719
if ($changes) {
1820
Write-Error "Changes detected in PublicApi.Shipped.txt files. Public API changes must be shipped through the release process, not in regular pull requests."
@@ -21,15 +23,13 @@ jobs:
2123
shell: pwsh
2224
- name: Label based on PublicApi.Unshipped.txt
2325
run: |
24-
git fetch origin ${{ github.base_ref }}
25-
2626
# Determine the appropriate label (Sync these labels with release-drafter.yml)
2727
if ("${{ github.ref }}" -eq "action/ship-publicapi") { # Same branch name specified in Release.yml
2828
$labels = @('Type/Housekeeping')
2929
Write-Output "This is a ship-publicapi PR, labeling as Type/Maintenance"
3030
} else {
3131
# For regular PRs, check for API changes
32-
$changes = git diff origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Unshipped.txt'
32+
$changes = git diff ${{ github.base_ref }}...${{ github.head_ref }} -- '**/PublicApi.Unshipped.txt'
3333
Write-Output "$changes"
3434
3535
if ($changes) {

0 commit comments

Comments
 (0)