-
Notifications
You must be signed in to change notification settings - Fork 69
100 lines (85 loc) · 3.33 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Check links on Academy
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches:
- "jamon-chainlink"
defaults:
run:
shell: bash
working-directory: ./tools/chainlink
jobs:
check-links:
runs-on: ubuntu-latest
if: github.repository == 'chainguard-dev/edu'
permissions:
issues: write # opens issues when bad links are found
steps:
- name: 'Github Actions Runner'
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: 'Checkout default branch to $GITHUB_WORKSPACE dir'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install jq
run: |
sudo apt update
sudo apt install -y jq
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Set up Go
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # actions/setup-go@v4
with:
go-version: '^1.20.0'
- name: Run chainlink
run: go run . -contentDir ../../content -hostname edu.chainguard.dev -method GET -checkAll
- name: Find unchecked links
run: |
jq -r '.unchecked []?| {"url":.rawurl, "files":(.files |keys)}' results.json |\
jq -s |\
yq -P > unchecked.json
- name: Find 404 links
run: |
jq '.checked []?| select(.status == 404) | {"url":.rawurl, "files":(.files |keys)}' results.json |\
jq -s |\
yq -P > checked.json
- name: Create issue body
run: |
printf '## Unchecked URLs:\n```\n' > issue-body.txt
cat unchecked.json >> issue-body.txt
printf '```\n\n## 404 URLs\n```\n' >> issue-body.txt
cat checked.json >> issue-body.txt
printf '```\n\n' >> issue-body.txt
printf '## Notes\nAdd any of the unchecked or 404 URLs to `ignore.json` as required' >> issue-body.txt
- name: Create/Update GitHub Issue
env:
GH_TOKEN: ${{ github.token }}
run: |
existing=$(gh issue list --json number,title |\
jq -r '.[] | select(.title == "[chainlink] check links on edu.chainguard.dev") | .number')
if [ -z "${existing}" ]; then
gh issue create \
--title "[chainlink] check links on edu.chainguard.dev" \
--assignee jamonation \
--label automated \
--body-file issue-body.txt
else
gh issue edit $existing --body-file issue-body.txt
fi
- name: Post failure notice to Slack
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # v2.3.2
if: ${{ failure() }}
env:
SLACK_ICON: http://github.com/chainguard-dev.png?size=48
SLACK_USERNAME: guardian
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: 'alerts-edu'
SLACK_COLOR: '#8E1600'
MSG_MINIMAL: 'true'
SLACK_TITLE: 'Check Links failed - ${{ github.repository }}'
SLACK_MESSAGE: |
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}