-
Notifications
You must be signed in to change notification settings - Fork 72
Fix workflows #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix workflows #256
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,20 @@ | ||
| name: Label breaking changes for semantic versioning | ||
|
|
||
| on: [pull_request] | ||
| on: pull_request_target # Run on the merge target branch instead of the merge commit to grant pull-requests:write permission | ||
| jobs: | ||
| Label: | ||
| runs-on: windows-latest | ||
| permissions: | ||
| pull-requests: write # Allow adding a label to this pull request | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| submodules: recursive | ||
| fetch-depth: 0 # Fetch all commit history and tags, instead of the default fetch of only one commit | ||
| ref: ${{ github.event.pull_request.head.sha }} # Checkout the PR branch | ||
|
Comment on lines
+3
to
+13
|
||
| - name: If there are changes in PublicApi.Shipped.txt, fail the workflow | ||
| if: github.head_ref != 'action/ship-publicapi' # Same branch name specified in Release.yml | ||
| run: | | ||
| git fetch origin ${{ github.base_ref }} | ||
| $changes = git diff --numstat --shortstat origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Shipped.txt' | ||
| $changes = git diff --numstat --shortstat origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Shipped.txt' # Note that ** must expand to at least one folder here, this doesn't check root | ||
|
||
| Write-Output "$changes" | ||
| if ($changes) { | ||
| 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,12 +23,9 @@ jobs: | |
| shell: pwsh | ||
| - name: Label based on PublicApi.Unshipped.txt | ||
| run: | | ||
| git fetch origin ${{ github.base_ref }} | ||
|
|
||
| # Determine the appropriate label (Sync these labels with release-drafter.yml) | ||
| if ("${{ github.head_ref }}" -eq "action/ship-publicapi") { # Same branch name specified in Release.yml | ||
| if ("${{ github.head_ref }}" -eq "action/ship-publicapi") { | ||
| $labels = @('Type/Housekeeping') | ||
| Write-Output "This is a ship-publicapi PR, labeling as Type/Maintenance" | ||
| Write-Output "This is a ship-publicapi PR, labeling as Type/Housekeeping" | ||
| } else { | ||
| # For regular PRs, check for API changes | ||
| $changes = git diff origin/${{ github.base_ref }}...HEAD -- '**/PublicApi.Unshipped.txt' | ||
|
||
|
|
@@ -44,8 +43,8 @@ jobs: | |
| Write-Output "Publicly facing API changes include only additions. Labelling as enhancement." | ||
| } | ||
| } else { | ||
| $labels = @('Type/Bug') | ||
| Write-Output "No publicly facing API changes. Labelling as bug." | ||
| Write-Output "No publicly facing API changes. Exiting the workflow." | ||
| Exit | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states that the workflow runs "on the merge target branch instead of the merge commit", but the checkout configuration uses
ref: ${{ github.event.pull_request.head.sha }}which checks out the PR branch (head), not the target branch (base). The comment may be misleading. Thepull_request_targetevent does run in the context of the base repository (for permissions), but the code being checked out is from the PR head.