-
Notifications
You must be signed in to change notification settings - Fork 2
161 lines (138 loc) · 5.52 KB
/
documentation.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: documentation
on:
# Triggers the workflow on push but only for the main branch
push:
branches: [ main ]
tags: [ v* ]
paths:
- sed/**/*
- tutorial/**
- .github/workflows/documentation.yml
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 2048
swap-size-mb: 1024
remove-dotnet: 'true'
remove-codeql: 'true'
remove-android: 'true'
remove-docker-images: 'true'
# Check out repo and set up Python
- name: Check out the repository
uses: actions/checkout@v4
with:
lfs: true
# Use cached python and dependencies, install poetry
- name: "Setup Python, Poetry and Dependencies"
uses: packetcoders/action-setup-cache-python-poetry@main
with:
python-version: 3.9
poetry-version: 1.8.3
- name: Install notebook dependencies
run: poetry install -E notebook --with docs
- name: Install pandoc
run: |
sudo wget https://github.com/jgm/pandoc/releases/download/3.1.8/pandoc-3.1.8-1-amd64.deb
sudo dpkg -i pandoc-3.1.8-1-amd64.deb
# rm because hextof_workflow notebook can not run outside maxwell
- name: copy tutorial files to docs
run: |
cp -r $GITHUB_WORKSPACE/tutorial $GITHUB_WORKSPACE/docs/
cp -r $GITHUB_WORKSPACE/sed/config $GITHUB_WORKSPACE/docs/sed
- name: download RAW data
# if: steps.cache-primes.outputs.cache-hit != 'true'
run: |
cd $GITHUB_WORKSPACE/docs
poetry run python scripts/download_data.py
- name: build parquet files
run: |
cd $GITHUB_WORKSPACE/docs
poetry run python scripts/build_flash_parquets.py
poetry run python scripts/build_sxp_parquets.py
# to be removed later. This theme doesn't support <3.9 python and our lock file contains 3.8
- name: install pydata-sphinx-theme
run: |
poetry run pip install pydata-sphinx-theme
- name: Change version for develop build
if: startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/main'
run: |
VERSION=`sed -n 's/^version = "\(.*\)".*/\1/p' $GITHUB_WORKSPACE/pyproject.toml`
MOD_VERSION=$VERSION".dev0"
echo $MOD_VERSION
sed -i "s/^version = \"$VERSION\"/version = \"$MOD_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml
- name: Change version for release build
if: startsWith(github.ref, 'refs/tags/')
run: |
OLD_VERSION=`sed -n 's/^version = "\(.*\)".*/\1/p' $GITHUB_WORKSPACE/pyproject.toml`
NEW_VERSION=`echo ${GITHUB_REF#refs/tags/} | sed -n 's/^v\(.*\)/\1/p'`
echo $NEW_VERSION
sed -i "s/^version = \"$OLD_VERSION\"/version = \"$NEW_VERSION\"/" $GITHUB_WORKSPACE/pyproject.toml
- name: build Sphinx docs
run: poetry run sphinx-build -b html $GITHUB_WORKSPACE/docs $GITHUB_WORKSPACE/_build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: sphinx-docs
path: _build
# this job pushes the built documentation to the docs repository
push:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout docs repo
uses: actions/checkout@v2
with:
repository: ${{ github.repository_owner }}/docs
token: ${{ secrets.GITHUB_TOKEN }}
path: 'docs-repo'
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_DOCS_DEPLOY_KEY }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: sphinx-docs
path: sphinx-docs
- name: Determine version folder
id: version-folder
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
echo "folder=sed/$VERSION" >> $GITHUB_OUTPUT
rm docs-repo/sed/stable
ln -s -r docs-repo/sed/$VERSION docs-repo/sed/stable
elif [[ $GITHUB_REF == refs/heads/main ]]; then
echo "folder=sed/latest" >> $GITHUB_OUTPUT
else
echo "folder=sed/develop" >> $GITHUB_OUTPUT
fi
- name: Update switcher.json
run: |
VERSION=`grep "<title>SED documentation." sphinx-docs/index.html | sed -n 's/.*SED \(.*\) documentation.*/\1/p'`
echo "python docs-repo/sed/update_switcher.py docs-repo/sed/switcher.json $GITHUB_REF $VERSION"
python docs-repo/sed/update_switcher.py docs-repo/sed/switcher.json $GITHUB_REF $VERSION
- name: Copy documentation to the right version folder
run: |
mkdir -p docs-repo/${{ steps.version-folder.outputs.folder }}
cp -r sphinx-docs/* docs-repo/${{ steps.version-folder.outputs.folder }}
rm -rf docs-repo/${{ steps.version-folder.outputs.folder }}/.doctrees
rm -rf docs-repo/${{ steps.version-folder.outputs.folder }}/tutorial/*.ipynb
- name: Push changes
run: |
cd docs-repo
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Update documentation"
git push