Skip to content

Commit b3f8f98

Browse files
Update check-broken-links.yml
1 parent 61831a3 commit b3f8f98

File tree

1 file changed

+16
-40
lines changed

1 file changed

+16
-40
lines changed

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

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ name: Daily Broken Link Check
22

33
on:
44
schedule:
5-
- cron: '0 2 * * *'
5+
- cron: '0 2 * * *' # Every day at 2:00 AM UTC
66
workflow_dispatch:
77

88
jobs:
9-
broken-link-check:
9+
lychee:
10+
name: Broken Link Checker
1011
runs-on: ubuntu-latest
12+
1113
steps:
12-
- uses: actions/checkout@v4
14+
- name: Checkout code
15+
uses: actions/checkout@v4
1316

1417
- name: Run Lychee link checker
1518
id: lychee
@@ -21,43 +24,16 @@ jobs:
2124
--no-progress
2225
--exclude ^https?://
2326
'**/*.md'
24-
output: lychee/out.md
27+
output: lychee/out.md # ✅ Set output file here, not in args
2528
env:
2629
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2730

28-
- name: Detect broken links
29-
id: detect
30-
run: |
31-
if [ -s lychee/out.md ]; then
32-
echo "has_issues=true" >> $GITHUB_OUTPUT
33-
else
34-
echo "has_issues=false" >> $GITHUB_OUTPUT
35-
fi
36-
37-
- name: Create or update GitHub Issue
38-
if: steps.detect.outputs.has_issues == 'true'
39-
env:
40-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
run: |
42-
TITLE="Broken Links Detected"
43-
BODY="$(cat lychee/out.md)"
44-
echo "Searching for existing issue..."
45-
gh issue list \
46-
--state open \
47-
--label bug,links \
48-
--search "$TITLE" \
49-
--json number,title \
50-
> issues.json
51-
52-
ISSUE_NUM=$(jq -r '.[] | select(.title==env.TITLE) | .number' issues.json)
53-
54-
if [ -n "$ISSUE_NUM" ]; then
55-
echo "Updating issue #$ISSUE_NUM"
56-
gh issue edit "$ISSUE_NUM" --body "$BODY"
57-
else
58-
echo "Creating new issue"
59-
gh issue create \
60-
--title "$TITLE" \
61-
--body "$BODY" \
62-
--label "bug,links"
63-
fi
31+
- name: Create or update GitHub Issue if broken links found
32+
if: failure()
33+
uses: peter-evans/create-issue-from-file@v4
34+
with:
35+
title: "Broken Links Detected"
36+
content-filepath: lychee/out.md
37+
labels: bug, links
38+
update-existing: true
39+
issue-pattern: "Broken Links Detected"

0 commit comments

Comments
 (0)