-
Notifications
You must be signed in to change notification settings - Fork 45
74 lines (71 loc) · 2.07 KB
/
publish_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
name: Publish documentation
on:
push:
branches:
- master
tags:
- v*
jobs:
deploydocs:
runs-on: ubuntu-22.04
timeout-minutes: 32
permissions:
# NOTE: Needed to push to the repository.
contents: write
steps:
- uses: actions/checkout@v3
with:
path: polytracker
- name: Get the version
id: get_version
run: echo "::set-env name=VERSION::${GITHUB_REF#refs/*/}"
env:
# The use of ::set-env here is safe!
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
cd polytracker
python -m pip install --upgrade pip
pip install setuptools
pip install .[dev]
- name: Build documentation
run: |
cd polytracker/docs
make html
- name: Checkout gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
fetch-depth: 0
- name: Commit documentation changes
run: |
cd gh-pages
git pull
rm -rf ${VERSION}
mkdir ${VERSION}
cp -r ../polytracker/docs/_build/html/* ${VERSION}/
cd ${VERSION}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
if [ "$GITHUB_REF" == "refs/heads/master" ]; then
cd ..
# This is not tag, so it is the latest:
rm -f latest
ln -s ${VERSION} latest
git add latest
fi
git commit -m "Update documentation for ${GITHUB_REF}" -a || true
# The above command will fail if no changes were present, so we ignore
# the return code.
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}