Skip to content

Commit 2966f6b

Browse files
fix: validate added pull request links safely
Signed-off-by: John Finnerty <297514060+johnfinnerty-nz@users.noreply.github.com>
1 parent 4839f59 commit 2966f6b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎.github/workflows/pr-preview-links.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request_target:
55
types:
66
- opened
7+
- reopened
8+
- synchronize
79

810
permissions:
911
contents: read
@@ -17,17 +19,19 @@ jobs:
1719
documentation-links:
1820
runs-on: ubuntu-latest
1921
steps:
20-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2123
with:
22-
fetch-depth: 0
24+
fetch-depth: 2
25+
ref: refs/pull/${{ github.event.pull_request.number }}/merge
2326

2427
- name: Extract links added by the pull request
2528
run: |
26-
git diff --unified=0 "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" -- '*.md' '*.rst' \
29+
git diff --unified=0 HEAD^1 HEAD^2 -- '*.md' '*.rst' \
30+
| grep '^+' | grep -v '^+++' \
2731
| grep -Eo 'https?://[^ )>]+' | sort -u > added-links.txt || true
2832
2933
- name: Check links added by the pull request
30-
uses: lycheeverse/lychee-action@v2
34+
uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2
3135
with:
3236
args: --verbose --no-progress --exclude-mail added-links.txt
3337
fail: true

0 commit comments

Comments
 (0)