forked from InstituteforDiseaseModeling/covasim
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (77 loc) · 2.86 KB
/
docs.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
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
name: Covasim Docs workflow
on:
push:
branches:
- master
jobs:
docs:
runs-on: ubuntu-latest
if: github.repository == 'InstituteforDiseaseModeling/covasim'
strategy:
fail-fast: false
max-parallel: 8
matrix:
python-version: ['3.7']
name: Install and Generate Docs
steps:
- name: Set repo owner env variable
shell: python
run: print("::set-env name=GITHUB_OWNER::{}".format('${{github.repository}}'.split('/')[0]))
- name: Set repo owner env variable
shell: python
run: print("::set-env name=GITHUB_OWNER::{}".format('${{github.repository}}'.split('/')[0]))
- name: Set PYTHONPATH
run: |
mkdir -p $HOME/.cache/site-packages
echo "::set-env name=PYTHONPATH::$HOME/.cache/site-packages"
- name: Checkout Docs Repo
uses: actions/checkout@v2
with:
repository: ${{ env.GITHUB_OWNER }}/covasim-docs
path: covasim-docs
ssh-key: '${{ secrets.DOCS_DEPLOY_KEY }}'
- name: Checkout sources
uses: actions/checkout@v2
with:
path: covasim
- uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Cache Packages
id: cache-packages
uses: actions/cache@v1
with:
path: ~/.cache/ # This path is specific to Ubuntu
key: docs-packages-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}--${{ hashFiles('docs/requirements.txt') }} # Look to see if there is a cache hit for the corresponding requirements file
restore-keys: |
docs-packages-${{ runner.os }}-${{ matrix.python-version }}- # Pip install first will make setup.py much faster and the cache will make pip install fast
- name: Install Covasim
run: |
pushd covasim
python setup.py develop --install-dir ~/.cache/site-packages
pip3 install -r docs/requirements.txt
popd
- name: Build Docs
run: |
pushd covasim/docs
make html
popd
rm -rf covasim-docs/*
rsync -r covasim/docs/_build/html/ covasim-docs/
- name: Commit Docs
run: |
pushd covasim-docs
if [ ! -z "$(git status --porcelain)" ]; then
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add --all .
git commit -m "Update Docs"
# Setup deploy key
eval "$(ssh-agent -s)"
ssh-add - <<< "${{ secrets.DOCS_DEPLOY_KEY }}"
# Deploy
remote_repo="[email protected]:${{ env.GITHUB_OWNER }}/covasim-docs.git"
git push "${remote_repo}" HEAD:${{ github.ref }} --follow-tags
fi
popd