-
Notifications
You must be signed in to change notification settings - Fork 9
136 lines (115 loc) · 3.71 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Publish Sphinx Docs to GitHub Pages
on:
# Build the docs on pushes to main branch, PRs to main branch, and new tags.
# Publish only on demand.
push:
branches:
- main
tags:
- "*" # all tags
pull_request:
branches:
- main
workflow_dispatch: # allow manual triggering
inputs:
deploy:
description: "Deploy documentation"
type: boolean
required: true
default: false
defaults:
run:
shell: bash -l {0}
jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # otherwise, you will get "failed to push refs to dest repo"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Deploy Information
if: ${{ github.event.inputs.deploy }}
run: |
echo "The will be published from this workflow run."
- name: Install pandoc
run: |
set -vxeuo pipefail
sudo apt-get update && \
sudo apt-get -y install pandoc
- name: Install Sphinx build requirements
run: |
pip install -r docs/requirements.txt
- name: Install our package
run: |
pip install --no-deps -e .
- name: Diagnostic
run: |
echo $(which pandoc)
echo $(which sphinx-build)
- name: Make Temporary Directory for Sphinx content
run: |
echo "SRC_DIR=$(pwd)" >> ${GITHUB_ENV}
echo "TMP_DIR=$(mktemp -d)" >> ${GITHUB_ENV}
# next step also creates _version.py file
echo "VERSION=$(python -m setuptools_scm)" >> ${GITHUB_ENV}
- name: Show Environment variables
run: |
echo "SRC_DIR=${SRC_DIR}"
echo "TMP_DIR=${TMP_DIR}"
echo "VERSION=${VERSION}"
- name: Sphinx
run: |
TZ=UTC sphinx-build -M html ./docs/source "${TMP_DIR}/build"
- name: Build Info
run: ls -lAFghR "${TMP_DIR}/build/html"
- name: Upload Docs ZIP file as artifact
uses: actions/upload-artifact@v4
with:
name: apstools-docs
path: ${{ env.TMP_DIR }}/build/html
- name: Re-build the master directory (contains all documentation versions)
run: |
set -vxeuo pipefail
cp .github/index.html "${TMP_DIR}"
cd "${TMP_DIR}"
mv build/html "${VERSION}"
/bin/rm -rf build
ln -s "./${VERSION}" dev
# add previous documentation (built versions)
# update the switcher.json file before a new release
wget https://github.com/BCDA-APS/apstools/archive/refs/heads/gh-pages.zip
unzip -q gh-pages.zip
/bin/rm gh-pages.zip
source "${SRC_DIR}/.github/scripts/define_versions.sh"
for v in ${versions}
do
if [ -d "apstools-gh-pages/${v}" ]
then
echo "directory 'apstools-gh-pages/${v}' exists"
mv "apstools-gh-pages/${v}" ./
latest="${v}"
fi
done
echo "latest=${latest}"
ln -s "./${latest}" ./latest
/bin/rm -rf apstools-gh-pages
- name: Info
run: |
set -vxeuo pipefail
cd "${TMP_DIR}"
echo "pwd=$(pwd)"
ls -laFGh
du -shc *
- name: Publish (push gh-pages branch) only on demand
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event.inputs.deploy }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.TMP_DIR }}
force_orphan: true