-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (89 loc) · 3.18 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
name: Docs
on:
push:
branches:
- main
# when a review is requested on a PR that targets `main`, or the PR is closed:
# pull_request:
# types: [review_requested, closed]
# Prevent multiple PRs from building/deploying the docs at the same time
concurrency:
group: ${{ github.workflow }}
jobs:
docs-build:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install package and dependencies
run: |
sudo apt-get install pandoc
pip install setuptools --upgrade
pip install .[test,docs]
- name: Make docs
run: |
cd docs
make html
# check code coverage, store results in the built docs.
# coverage.py creates a .gitignore with '*' where it's run; remove it
# to keep the coverage report and badge on gh-pages
- name: Coverage
# only continue if the PR is not just closed, but also merged:
# if: github.event.pull_request.merged == true
run: |
coverage run --source=py_template -m pytest test/*.py
coverage report
mkdir -p docs/_build/html/coverage
coverage html -d docs/_build/html/coverage
rm docs/_build/html/coverage/.gitignore
coverage-badge -f -o docs/_build/html/coverage/badge.svg
# upload the built docs as an artifact so the files can be accessed
# by a subsequent job in the workflow.
# only store the artifact for 'retention-days'
- name: Upload docs artifact
# if: github.event.pull_request.merged == true
uses: actions/upload-artifact@v4
with:
name: built_docs
path: docs/_build/html
retention-days: 1
docs-deploy:
name: Deploy docs
needs: docs-build
# if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
# download the previously uploaded 'built_docs' artifact
- name: Download docs artifact
uses: actions/download-artifact@v4
id: download
with:
name: built_docs
path: docs/_build/html
- name: Echo download path
run: echo ${{steps.download.outputs.download-path}}
- name: Disable jekyll builds
run: touch docs/_build/html/.nojekyll
- name: Display docs file structure
run: ls -aR
working-directory: docs/_build/html
- name: Install and configure dependencies
run: |
npm install -g --silent gh-pages@2.0.1
- name: Deploy docs to gh-pages branch
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages --dotfiles --dist docs/_build/html --user "github-actions-bot <support+actions@github.com>" --message "Update docs [skip ci]"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}