-
Notifications
You must be signed in to change notification settings - Fork 288
37 lines (35 loc) · 1.18 KB
/
broken-links-check.yaml
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
name: check-links
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare Yarn
uses: ./.github/actions/prepare/
- name: Build CLI
run: yarn build:cli
- name: Check Links
id: check-links
# Run link checker and save outputs to files. https://stackoverflow.com/a/692407
run: |
yarn lint:links > >(tee -a stdout.txt) 2> >(tee -a stderr.txt >&2)
- name: Create issue
uses: actions/[email protected]
if: always() && steps.check-links.outcome == 'failure'
with:
script: |
const fs = require('fs');
const input = fs.readFileSync('stderr.txt');
const data = JSON.parse(input);
const urls = data.map(item => item.url);
const output = urls.map(url => `- [ ] ${url}`).join('\n');
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Fix broken links',
body: `The following links are possibly broken:\n${output}`,
});