Debian Codegraph @

.github/workflows/links.yml

raw
1 name: Links
2
3 on:
4 repository_dispatch:
5 workflow_dispatch:
6 pull_request:
7 schedule:
8 - cron: "00 18 * * *"
9
10 jobs:
11 check-links:
12 runs-on: ubuntu-latest
13 permissions:
14 issues: write # required for Broken Links Report
15 steps:
16 - uses: actions/checkout@v7
17
18 - name: Link Checker
19 id: lychee
20 uses: lycheeverse/lychee-action@v2
21 with:
22 args: --config lychee.toml .
23 fail: false
24
25 - name: Broken Links Report
26 if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule'
27 uses: actions/github-script@v9
28 with:
29 script: |
30 const fs = require('fs');
31 const reportTitle = 'Broken Links Report';
32 const openIssues = await github.paginate(
33 github.rest.issues.listForRepo,
34 {
35 owner: context.repo.owner,
36 repo: context.repo.repo,
37 state: 'open',
38 per_page: 100
39 }
40 );
41
42 if (openIssues.some(issue =>
43 !issue.pull_request && issue.title === reportTitle
44 )) {
45 core.info(`An open "${reportTitle}" issue already exists; skipping.`);
46 return;
47 }
48
49 const reportBody = fs.readFileSync('./lychee/out.md', 'utf8');
50
51 await github.rest.issues.create({
52 owner: context.repo.owner,
53 repo: context.repo.repo,
54 title: reportTitle,
55 body: reportBody
56 });