-
Notifications
You must be signed in to change notification settings - Fork 98
53 lines (50 loc) · 2.17 KB
/
pr_ci.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
name: Build and check links in PRs
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install lychee
env:
LYCHEEVERSION: 0.13.0
# due to the limitation of Apache, we can't use lycheeverse/lychee-action directly,
# so we re-use some core code from it(install)
run: |
curl -sLO "https://github.com/lycheeverse/lychee/releases/download/v${{ env.LYCHEEVERSION }}/lychee-v${{ env.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvzf "lychee-v${{ env.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
rm "lychee-v${{ env.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
install -t "$HOME/.local/bin" -D lychee
rm lychee
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Link Checker
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
# For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters
# test external link for modified files only, the rest are tested by the docusaurus already
git diff --diff-filte=AMR --name-only ${{ github.event.pull_request.base.sha }}... | grep -P '\.md$' > modified_files || true
if [ -s modified_files ]; then
# run lychee
cat modified_files | xargs -d '\n' -- lychee -E -i -n -t 45 --max-concurrency 64 -a 409,401,403 -m 10 -s http -s https --
fi
- name: Use Node.js 17.8.x
uses: actions/setup-node@main
with:
node-version: 17.8.x
- name: Replace base url
run: |
# replace base url to localhost to support change of doc structure
sed -i 's#https://devlake.apache.org#http://local.devlake.apache.org#g' docusaurus.config.js
- name: Edit hosts
run: |
# why we need this:
# lychee will ignore links to localhost, so we need to add a new domain to avoid this
echo "127.0.0.1 local.devlake.apache.org" | sudo tee -a /etc/hosts
- name: Build Docusaurus website
run: |
npm install
npm run build