forked from X2CommunityCore/X2WOTCCommunityHighlander
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (107 loc) · 3.33 KB
/
docs.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
115
name: docs
on: [push, pull_request]
# Ensures that only one deploy task per branch/environment will run at a time.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Checkout
uses: actions/checkout@v3
- name: Test docs script
run: |
cd test/docs
! python ../../.scripts/make_docs.py ./test_src --outdir ./test_output --docsdir ./test_tags --dumpelt ./test_output/CHL_Event_Compiletest.uc > ./test_output/stdout.log
git diff --exit-code
check-event-templates:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Find generated event templates
id: make-diff
shell: bash {0}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
# Build base docs (master)
git checkout ${{ github.base_ref }}
mkdir target
python ./.scripts/make_docs.py --indirsfile ./docs_directories.txt --docsdir ./docs_src --dumpelt ./target/CHL_Event_Compiletest.uc
if [ $? -ne 0 ]
then
echo "master docs build broken?"
exit 1
fi
git add -f ./target/CHL_Event_Compiletest.uc
# Build PR merge docs
git checkout ${{ github.sha }}
python ./.scripts/make_docs.py --indirsfile ./docs_directories.txt --docsdir ./docs_src --dumpelt ./target/CHL_Event_Compiletest.uc
if [ $? -ne 0 ]
then
echo "PR docs fail -- should be caught by build job"
exit 1
fi
# Generate diff between master and PR merge
mkdir tmp_art
git diff --exit-code > tmp_art/new_contents.diff
if [ $? -eq 1 ]
then
echo "Difference found"
cat tmp_art/new_contents.diff
echo "has-diff=true" >> $GITHUB_OUTPUT
echo $PR_NUMBER > tmp_art/pr_number.txt
fi
- name: Upload the diff
if: ${{ steps.make-diff.outputs.has-diff }}
uses: actions/upload-artifact@v1
with:
name: new_contents.diff
path: tmp_art/
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Checkout
uses: actions/checkout@v3
- name: Build Docs
run: |
python ./.scripts/make_docs.py --indirsfile ./docs_directories.txt --outdir ./mkdocs --docsdir ./docs_src
pip install mkdocs
cd mkdocs
mkdocs build -d ../target
- name: Upload the built docs
uses: actions/upload-artifact@v1
with:
name: docs-html
path: target
deploy:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Get the built docs
uses: actions/download-artifact@v1
with:
name: docs-html
path: target
- name: Deploy
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: target # The folder the action should deploy.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}