-
-
Notifications
You must be signed in to change notification settings - Fork 18
117 lines (105 loc) · 3.19 KB
/
linkchecker.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Check for broken links
on:
workflow_dispatch:
schedule:
# Run every weekend
- cron: '0 2 * * 6'
jobs:
url:
runs-on: ubuntu-latest
outputs:
url: ${{ steps.get-url.outputs.url }}
steps:
- name: Get URL
id: get-url
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -ex
url=$(gh api --jq .html_url repos/${{ github.repository }}/pages)
echo "url=$url" >> $GITHUB_OUTPUT
# internal and external links
linkchecker:
needs: url
runs-on: ubuntu-latest
env:
LINKCHECKER_FLAGS: ''
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: 'pip'
cache-dependency-path: |
.github/workflows/linkchecker.yaml
- name: Install linkchecker
run: |
pip3 install 'LinkChecker >= 10.2'
- id: attempt1
continue-on-error: true
name: Run linkchecker
run: |
linkchecker --check-extern ${{ env.LINKCHECKER_FLAGS }} ${{ needs.url.outputs.url }}
- name: Sleep
if: steps.attempt1.outcome == 'failure'
run: sleep 30
- id: attempt2
if: steps.attempt1.outcome == 'failure'
continue-on-error: true
name: Run linkchecker
run: |
linkchecker --check-extern ${{ env.LINKCHECKER_FLAGS }} ${{ needs.url.outputs.url }}
- name: Sleep
if: steps.attempt2.outcome == 'failure'
run: sleep 30
- id: attempt3
if: steps.attempt2.outcome == 'failure'
continue-on-error: true
name: Run linkchecker
run: |
linkchecker --check-extern ${{ env.LINKCHECKER_FLAGS }} ${{ needs.url.outputs.url }}
- name: Fail
if: steps.attempt1.outcome == 'failure' && steps.attempt2.outcome == 'failure' && steps.attempt3.outcome == 'failure'
run: false
# internal links and anchors
linkcheck:
needs: url
runs-on: ubuntu-latest
steps:
- id: attempt1
continue-on-error: true
name: Run linkcheck
uses: filiph/[email protected]
with:
arguments: ${{ needs.url.outputs.url }}
- name: Sleep
if: steps.attempt1.outcome == 'failure'
run: sleep 30
- id: attempt2
if: steps.attempt1.outcome == 'failure'
continue-on-error: true
name: Run linkcheck
uses: filiph/[email protected]
with:
arguments: ${{ needs.url.outputs.url }}
- name: Sleep
if: steps.attempt2.outcome == 'failure'
run: sleep 30
- id: attempt3
if: steps.attempt2.outcome == 'failure'
continue-on-error: true
name: Run linkcheck
uses: filiph/[email protected]
with:
arguments: ${{ needs.url.outputs.url }}
- name: Fail
if: steps.attempt1.outcome == 'failure' && steps.attempt2.outcome == 'failure' && steps.attempt3.outcome == 'failure'
run: false
workflow-keepalive:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: liskin/gh-workflow-keepalive@v1