Skip to content

Commit 457430d

Browse files
Copilothotlong
andcommitted
Improve link checker workflow security and consistency
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 74ad59e commit 457430d

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

.github/workflows/check-links.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@v4
2222

2323
- name: Check links with lychee
24-
uses: lycheeverse/lychee-action@v2
24+
uses: lycheeverse/lychee-action@2b973e86fc5181cd4fdfd5829efc58d4dd49a2c4 # v2.0.2
2525
with:
2626
# Scan all markdown and MDX files in content directory, plus root README
2727
args: >-
@@ -33,17 +33,18 @@ jobs:
3333
'README.md'
3434
# Fail the job if broken links are found
3535
fail: true
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3638

3739
- name: Create Issue on Failure
3840
if: failure()
39-
uses: actions/github-script@v7
41+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
4042
with:
4143
script: |
42-
const output = process.env.LYCHEE_OUTPUT || 'Link check failed';
4344
github.rest.issues.create({
4445
owner: context.repo.owner,
4546
repo: context.repo.repo,
4647
title: '🔗 Broken links detected in documentation',
47-
body: `Link checker found broken links in the documentation.\n\nPlease review the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details.\n\n${output}`,
48+
body: `Link checker found broken links in the documentation.\n\nPlease review the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details.`,
4849
labels: ['documentation', 'bug']
4950
});

.lycheeignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ https://example.org
1111
http://example.com
1212
http://example.org
1313

14-
# Social media (防止反爬虫机制误报)
14+
# Social media (prevents anti-bot false positives)
1515
https://twitter.com*
1616
https://x.com*
1717

0 commit comments

Comments
 (0)