-
Notifications
You must be signed in to change notification settings - Fork 43
51 lines (41 loc) · 1.66 KB
/
check-links.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Check broken links
on:
deployment:
schedule:
- cron: "0 13 * * *"
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: npm install -g [email protected]
- name: Check links
run: linkinator https://docs.pimlico.io https://pimlico.io -r --retry --format json --skip api.pimlico.io --skip dashboard.pimlico.io --concurrency 5 > links-report.json
- name: Prepare report
id: prepare-report
run: |
LENGTH=$(jq '[.links[] | select(.state == "BROKEN" and .status!=403 and .status!=429 and .status!=0 and .status!=304)] | length' links-report.json)
if [ "$LENGTH" -gt 0 ]; then
echo "send_report=true" >> $GITHUB_OUTPUT
else
echo "send_report=false" >> $GITHUB_OUTPUT
fi
{
echo 'report_message<<EOF'
echo 'Broken links found in the docs 😱:'
jq -r '.links[] | select(.state == "BROKEN" and .status!=403 and .status!=429 and .status!=0 and .status!=304) | "• `\(.url)` (status: `\(.status)`) on the page \(.parent)"' links-report.json
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Send report
uses: slackapi/[email protected]
if: steps.prepare-report.outputs.send_report == 'true'
with:
channel-id: ${{ vars.REPORTS_CHANNEL_ID }}
slack-message: ${{ steps.prepare-report.outputs.report_message }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}