|
13 | 13 | - '**/*.rst' |
14 | 14 | - '.github/workflows/check-links.yml' |
15 | 15 | - '.github/workflows/check_links_config.json' |
| 16 | + merge_group: |
| 17 | + paths: |
| 18 | + - '**/*.md' |
| 19 | + - '**/*.rst' |
| 20 | + - '.github/workflows/check-links.yml' |
| 21 | + - '.github/workflows/check_links_config.json' |
16 | 22 |
|
17 | 23 | permissions: |
18 | 24 | contents: read |
19 | 25 |
|
20 | 26 | concurrency: |
21 | | - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} |
| 27 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_sha || github.run_id }} |
22 | 28 | cancel-in-progress: true |
23 | 29 |
|
| 30 | +env: |
| 31 | + # Diff against merge group SHAs in queue, or PR base branch otherwise |
| 32 | + DIFF_RANGE: ${{ github.event_name == 'merge_group' && format('{0}...{1}', github.event.merge_group.base_sha, github.event.merge_group.head_sha) || format('origin/{0}...HEAD', github.base_ref) }} |
| 33 | + |
24 | 34 | jobs: |
25 | 35 | check-links: |
26 | 36 | runs-on: ubuntu-latest |
@@ -53,14 +63,14 @@ jobs: |
53 | 63 | ${{ steps.changed-files.outputs.all_changed_files }} \ |
54 | 64 | || { echo "Check that anchor links are lowercase"; exit 1; } |
55 | 65 |
|
56 | | - - name: Check new links only on pull requests |
57 | | - if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request' |
| 66 | + - name: Check new links only on pull requests and merge groups |
| 67 | + if: steps.changed-files.outputs.any_changed == 'true' && (github.event_name == 'pull_request' || github.event_name == 'merge_group') |
58 | 68 | run: | |
59 | 69 | # Extract URLs only from added lines in the diff to avoid |
60 | 70 | # rate limiting when checking all links in large files like |
61 | 71 | # CHANGELOG.md. Only new/changed links are checked on PRs; |
62 | 72 | # pushes to main still check all links in changed files. |
63 | | - git diff "origin/${{ github.base_ref }}...HEAD" -- \ |
| 73 | + git diff "$DIFF_RANGE" -- \ |
64 | 74 | ${{ steps.changed-files.outputs.all_changed_files }} \ |
65 | 75 | | grep '^+' | grep -v '^+++' \ |
66 | 76 | | grep -oP 'https?://[^\s\)\]\"'"'"'`>]+' \ |
|
0 commit comments