-
-
Notifications
You must be signed in to change notification settings - Fork 5
67 lines (57 loc) · 1.86 KB
/
links-scheduled-issue.yml
File metadata and controls
67 lines (57 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Links (Scheduled → Issue)
on:
workflow_dispatch:
schedule:
- cron: "0 11 * * 1" # Mondays 11:00 UTC
permissions:
contents: read
issues: write
jobs:
lychee:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run lychee and write report
id: lychee
uses: lycheeverse/lychee-action@v2
with:
args: >
--config lychee.toml
--verbose
--no-progress
--output lychee-report.md
--format markdown
**/*.md
continue-on-error: true
- name: Create or update issue if broken links found
if: steps.lychee.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const title = 'Broken links detected';
const reportPath = 'lychee-report.md';
const report = fs.existsSync(reportPath) ? fs.readFileSync(reportPath, 'utf8') : '(No report file found)';
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100
});
const existing = issues.find(i => i.title === title);
const body = `This is an automated report from a scheduled link check.\n\n${report}`;
if (existing) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.number,
body
});
} else {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body
});
}