Skip to content

Commit e178466

Browse files
committed
fix(actions): lychee broken link commenting
1 parent 31c1c67 commit e178466

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/check-external-links.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ jobs:
3333
docs
3434
env:
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Prepare broken link report
37+
id: lychee_report
38+
if: ${{ steps.lychee.outputs.exit_code && steps.lychee.outputs.exit_code != '0' }}
39+
shell: bash
40+
run: |
41+
report_file="lychee/out.md"
42+
if [[ ! -s "$report_file" ]]; then
43+
echo "report<<EOF" >> "$GITHUB_OUTPUT"
44+
echo "Lychee detected broken links, but the report file (\`$report_file\`) was empty or missing." >> "$GITHUB_OUTPUT"
45+
echo "EOF" >> "$GITHUB_OUTPUT"
46+
exit 0
47+
fi
48+
49+
echo "report<<EOF" >> "$GITHUB_OUTPUT"
50+
cat "$report_file" >> "$GITHUB_OUTPUT"
51+
echo "EOF" >> "$GITHUB_OUTPUT"
3652
- name: Comment on PR if broken links found
3753
if: ${{ steps.lychee.outputs.exit_code && steps.lychee.outputs.exit_code != '0' }}
3854
uses: thollander/actions-comment-pull-request@v3
@@ -42,9 +58,7 @@ jobs:
4258
<details>
4359
<summary>Click to expand</summary>
4460
45-
```markdown
46-
${{ steps.lychee.outputs.report }}
47-
```
61+
${{ steps.lychee_report.outputs.report }}
4862
</details>
4963
env:
5064
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)