-
Notifications
You must be signed in to change notification settings - Fork 59
114 lines (103 loc) · 3.66 KB
/
PR-checks.yml
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
name: on PR
# This workflow is triggered on pull requests to the repository.
# It runs a job to build the docvs, and check for broken links in the files changed in the PR on the built static pages.
# It checks for spelling errors in the files changed in the PR.
on:
pull_request
jobs:
build:
name: 📦 Build & 🌍 Check links
runs-on: ubuntu-latest
outputs:
html_lychee_exited: ${{ steps.stringify.outputs.lychee_exited }}
html_lychee_file: ${{ steps.stringify.outputs.lychee_file }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- run: pip install nbconvert==7.0.0 packaging
- name: Convert Jupyter notebooks
run: |
shopt -s globstar
jupyter-nbconvert --to markdown **/*.ipynb --ExtractOutputPreprocessor.enabled=False
shopt -u globstar
shell: bash
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install vuepress
run: yarn global add vuepress
- name: Install package.json
run: yarn
- name: Build static site with vuepress
# alias for vuepress build src defined in package.json
run: yarn build
- name: Get size of files in dist
shell: bash
run: |
du -ah src/.vuepress/dist
- name: 'Get built html files'
id: html-files
run: |
html_files=$(find src/.vuepress/dist -name '*.html')
html_files="${html_files//$'\n'/ }"
html_files="${html_files//$'\r'/ }"
echo $html_files
echo "all_html_files=${html_files}" >> $GITHUB_OUTPUT
- name: 'Check Links'
id: lychee
uses: lycheeverse/[email protected]
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
args: -v -n -a 403,503,429,200 -i -b 'src/.vuepress/dist' --exclude-mail --include-verbatim -- ${{ steps.html-files.outputs.all_html_files }}
output: ./lychee/htmlfiles.md
jobSummary: true
- name: 'Outputs as strings'
id: stringify
run: |
EXIT_CODE_STRING="$( printf '%d' "${{ env.lychee_exit_code }}" )"
echo "lychee_exited=${EXIT_CODE_STRING}" >> $GITHUB_OUTPUT
if [ $EXIT_CODE_STRING -eq 0 ]; then
echo "lychee_file=No broken links found" >> $GITHUB_OUTPUT
exit 0
fi
if [ $EXIT_CODE_STRING -eq 1 ]; then
MD_OUT="$( cat ./lychee/htmlfiles.md )"
MD_OUT="${MD_OUT//'%'/'%25'}"
MD_OUT="${MD_OUT//$'\n'/'%0A'}"
MD_OUT="${MD_OUT//$'\r'/'%0D'}"
echo "text<<EOF" >> $GITHUB_OUTPUT
echo "$MD_OUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "lychee_file=${MD_OUT}" >> $GITHUB_OUTPUT
fi
link_fail:
name: 🚨 Fail if links are broken
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.html_lychee_exited != 0 }}
steps:
- name: 'Fail if links are broken'
run: |
echo "Some links are broken"
exit 1
check_spelling:
name: ✍️ Check spelling
runs-on: ubuntu-latest
outputs:
fail_spelling: ${{ steps.fail.outputs.fail_spelling }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: 'Check Grammar'
id: cspell
uses: streetsidesoftware/cspell-action@v2
with:
files: |
**/*.{md,html,ipynb}
strict: false
verbose: true