-
Notifications
You must be signed in to change notification settings - Fork 1k
75 lines (62 loc) · 2.73 KB
/
link-checker-pr.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
name: Link Checker (PR Build)
on:
# Note: DO NOT change this to "pull request_target" since that grants
# permission for PRs from random forks to modify the repo itself!
pull_request:
types: [opened, edited, synchronize]
jobs:
build:
name: "Build and Check Links"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install dactyl lxml
- name: Check for Conflict Markers
run: |
tool/conflictmarkers.sh
- name: Build docs
run: |
echo '{"github_forkurl": "https://github.com/${{ github.event.pull_request.head.repo.full_name }}", "github_branch": "${{ github.head_ref }}", "github_pr_id": "${{ github.event.number }}", "is_pr_build": true}' > dactyl_vars.json
tool/build_all_langs.sh --vars dactyl_vars.json
- name: Run Dactyl Link Checker
continue-on-error: true
id: linkcheck
run: |
dactyl_link_checker -o -q > linkreport.txt
- name: Assemble Link Report
run: |
sed -i '1,/---------------------------------------/d' linkreport.txt
echo 'LINKREPORT<<EOF' >> $GITHUB_ENV
head -c 65300 linkreport.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
cat linkreport.txt
- name: Run Style Checker
continue-on-error: true
run: dactyl_style_checker -q > out/style_report.txt
# This only works with PRs that are in-repo, not from forks.
# TODO: delete folders from gh-pages when PRs are closed
- name: Deploy to gh-pages
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
destination_dir: ./pr-preview/${{ github.head_ref }}
- name: Summarize Output
if: ${{ !github.event.pull_request.head.repo.fork }}
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: "${{ env.LINKREPORT }}\n\nPreview: https://${{ github.repository_owner }}.github.io/${{ github.event.pull_request.base.repo.name }}/pr-preview/${{ github.head_ref }}/\n\n[Style Report](https://${{ github.repository_owner }}.github.io/${{ github.event.pull_request.base.repo.name }}/pr-preview/${{ github.head_ref }}/style_report.txt)"
# Workaround for https://github.com/actions/toolkit/issues/399
# to mark the CI as failed if the link checker found broken links.
- name: Mark Failure
if: steps.linkcheck.outcome != steps.linkcheck.conclusion
run: exit 1