-
Notifications
You must be signed in to change notification settings - Fork 43
55 lines (47 loc) · 1.59 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
52
53
54
55
name: Check broken links
on:
deployment:
# push:
# branches:
# - main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: npm install -g linkinator
- name: Check links
run: linkinator https://docs.pimlico.io -r --format json > links-report.json
- name: Prepare report
id: prepare-report
run: |
LENGTH=$(jq '[.links[] | select(.state == "BROKEN")] | length' links-report.json)
if [ "$LENGTH" -gt 0 ]; then
echo "send_report=true" >> $GITHUB_OUTPUT
else
echo "send_report=false" >> $GITHUB_OUTPUT
fi
REPORT_LIST=$(jq '[.links[] | select(.state == "BROKEN") | "- `\(.url)` (status: `\(.status)`) on the page \(.parent)"] | join(" \n")' links-report.json)
echo "report_list=$REPORT_LIST" >> $GITHUB_OUTPUT
- name: Send report
uses: slackapi/[email protected]
if: steps.prepare-report.outputs.send_report == 'true'
with:
channel-id: "#alerts-test"
payload: |
{
"text": "Report",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ${{ steps.prepare-report.outputs.report_list }}
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}