Skip to content

Commit fb09a31

Browse files
authored
Update link checking workflow for multiple branches
1 parent 0f2e99e commit fb09a31

File tree

2 files changed

+68
-32
lines changed

2 files changed

+68
-32
lines changed

.github/workflows/check-links.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Check Links
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- '**/*.md'
10+
- '.github/workflows/check-links.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- dev
15+
paths:
16+
- '**/*.md'
17+
- '.github/workflows/check-links.yml'
18+
schedule:
19+
# Run weekly on Monday at 00:00 UTC
20+
- cron: '0 0 * * 1'
21+
workflow_dispatch:
22+
23+
jobs:
24+
lychee:
25+
name: Check Links in Markdown Files
26+
runs-on: ubuntu-latest
27+
28+
permissions:
29+
contents: read
30+
issues: write
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v5
35+
36+
- name: Check links with lychee
37+
uses: lycheeverse/lychee-action@v2
38+
with:
39+
args: --verbose --no-progress '**/*.md'
40+
fail: true
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Create issue if link check failed
45+
if: failure()
46+
uses: actions/github-script@v7
47+
with:
48+
script: |
49+
const title = '🔗 Broken links detected in markdown files';
50+
const body = `Link checker detected broken links in markdown files.\n\nPlease review the [workflow run](${context.payload.repository.html_url}/actions/runs/${context.runId}) for details.`;
51+
52+
// Check if issue already exists
53+
const issues = await github.rest.issues.listForRepo({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
state: 'open',
57+
labels: ['broken-links']
58+
});
59+
60+
if (issues.data.length === 0) {
61+
await github.rest.issues.create({
62+
owner: context.repo.owner,
63+
repo: context.repo.repo,
64+
title: title,
65+
body: body,
66+
labels: ['broken-links', 'documentation']
67+
});
68+
}

.github/workflows/lychee.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)