4
4
# Trigger the workflow on push
5
5
push :
6
6
# Selected branches
7
- branches : [develop, master , docs, patch]
7
+ branches : [master, develop , docs, patch]
8
8
# Runs on creating a new tag starting with 'v', e.g. 'v1.0.3'
9
9
tags :
10
10
- ' v*'
@@ -18,20 +18,24 @@ concurrency:
18
18
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19
19
cancel-in-progress : true
20
20
21
+ # Set the environment variables to be used in all jobs defined in this workflow
21
22
env :
22
- # Set the environment variables to be used in all jobs defined in this workflow
23
- # Set the CI_BRANCH environment variable to be the branch name
24
- # Set the NOTEBOOKS_DIR environment variable to be the directory containing the Jupyter notebooks
23
+ # CI_BRANCH - the branch name ( used in mkdocs.yml)
24
+ # GITHUB_REPOSITORY - the repository name (used in mkdocs.yml)
25
+ # NOTEBOOKS_DIR - the directory containing the Jupyter notebooks (used in mkdocs.yml)
25
26
CI_BRANCH : ${{ github.head_ref || github.ref_name }}
27
+ GITHUB_REPOSITORY : ${{ github.repository }}
26
28
NOTEBOOKS_DIR : tutorials
29
+ DEV_DEPLOYMENT_URL :
30
+ https://easyscience.github.io/${{ github.event.repository.name }}
31
+ PROD_DEPLOYMENT_URL : https://docs.easydiffraction.org/lib
27
32
28
33
jobs :
29
34
# Job 1: Build the static files for the documentation site
30
35
build-docs :
31
36
strategy :
32
37
matrix :
33
38
os : [macos-14] # Use macOS to switch to dark mode for Plotly charts
34
- python-version : ['3.13']
35
39
36
40
runs-on : ${{ matrix.os }}
37
41
49
53
git fetch --tags --force
50
54
echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
51
55
52
- # Without this step, GITHUB_REPOSITORY is not accessible from mkdocs.yml
53
- - name : Set GITHUB_REPOSITORY env variable
54
- run : echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> "$GITHUB_ENV"
55
-
56
56
# Activate dark mode to create documentation with Plotly charts in dark mode
57
57
# Need a better solution to automatically switch the chart colour theme based on the mkdocs material switcher
58
58
# Something similar to mkdocs_plotly_plugin https://haoda-li.github.io/mkdocs-plotly-plugin/,
@@ -64,85 +64,52 @@ jobs:
64
64
# dark-mode on
65
65
# dark-mode status
66
66
67
- - name : Set up Python ${{ matrix.python-version }}
68
- uses : actions /setup-python@v5
67
+ - name : Set up pixi
68
+ uses :
prefix-dev /setup-[email protected]
69
69
with :
70
- python-version : ${{ matrix.python-version }}
71
-
72
- - name : Upgrade package installer for Python
73
- shell : bash
74
- run : python -m pip install --upgrade pip
70
+ environments : >-
71
+ py313-docs
72
+ activate-environment : py313-docs
73
+ run-install : true
74
+ frozen : true
75
+ cache : false
76
+ post-cleanup : false
75
77
76
- # Install EasyDiffraction Library to run Jupyter notebooks
77
- # Install with the 'docs' and 'visualization' extras
78
- - name : Install EasyDiffraction Library and its dependencies
79
- run : python -m pip install .'[dev,docs,visualization]'
80
-
81
- # Clone assets extra from:
82
- # - easyscience/assets-docs
83
- # - easyscience/assets-branding
84
78
- name : Clone easyscience/assets-docs and easyscience/assets-branding
85
79
run : |
86
80
cd ..
87
81
git clone https://github.com/easyscience/assets-docs.git
88
82
git clone https://github.com/easyscience/assets-branding.git
89
83
90
- # Add the extra files from the easyscience/assets-docs repository
91
- - name : Add files from easyscience/assets-docs files
92
- run : |
93
- cp -R ../assets-docs/docs/assets/ docs/assets/
94
- cp -R ../assets-docs/includes/ includes/
95
- cp -R ../assets-docs/overrides/ overrides/
96
-
97
- # Add the extra files from the easyscience/assets-branding repository
98
- - name : Add files from easyscience/assets-branding files
99
- run : |
100
- mkdir -p docs/assets/images/
101
- cp ../assets-branding/easydiffraction/hero/dark.png docs/assets/images/hero_dark.png
102
- cp ../assets-branding/easydiffraction/hero/light.png docs/assets/images/hero_light.png
103
- cp ../assets-branding/easydiffraction/logos/dark.svg docs/assets/images/logo_dark.svg
104
- cp ../assets-branding/easydiffraction/logos/light.svg docs/assets/images/logo_light.svg
105
- cp ../assets-branding/easydiffraction/icons/color.png docs/assets/images/favicon.png
106
- mkdir -p overrides/.icons/
107
- cp ../assets-branding/easydiffraction/icons/bw.svg overrides/.icons/easydiffraction.svg
108
- cp ../assets-branding/easyscience-org/icons/eso-icon_bw.svg overrides/.icons/easyscience.svg
84
+ - name : Add files from cloned repositories
85
+ run : pixi run docs-assets
109
86
110
87
# Convert python scripts in the notebooks directory to Jupyter notebooks
111
- # Strip output from the notebooks, simpify cell ids and replace '# !pip' with '!pip'
112
- # The notebooks are used to generate the documentation
113
- - name :
114
- Convert ${{ env.NOTEBOOKS_DIR }}/*.py to docs/${{env.NOTEBOOKS_DIR
115
- }}/*.ipynb
116
- run : |
117
- cp -R ${{ env.NOTEBOOKS_DIR }}/data docs/${{ env.NOTEBOOKS_DIR }}/
118
- jupytext ${{ env.NOTEBOOKS_DIR }}/*.py --from py:percent --to ipynb
119
- nbstripout ${{ env.NOTEBOOKS_DIR }}/*.ipynb
120
- python tools/prepare_notebooks.py ${{ env.NOTEBOOKS_DIR }}/
121
- mv ${{ env.NOTEBOOKS_DIR }}/*.ipynb docs/${{ env.NOTEBOOKS_DIR }}/
122
-
123
- # The following step is needed to avoid the following message during the build:
124
- # "Matplotlib is building the font cache; this may take a moment"
125
- - name : Pre-build site step
126
- run : |
127
- export PYTHONPATH="$(pwd)/src${PYTHONPATH:+:$PYTHONPATH}"
128
- python -c "import easydiffraction"
88
+ # Strip output from the notebooks
89
+ # Prepare the notebooks for documentation (add colab cell, etc.)
90
+ # Run the notebooks to generate the output cells using multiple cores
91
+ # The notebooks are then used to build the documentation site
92
+ - name : Convert tutorial scripts to notebooks
93
+ run : pixi run notebook-prepare
94
+
95
+ - name : Run notebooks
96
+ run : pixi run notebook-exec
97
+
98
+ - name : Move notebooks to docs/tutorials
99
+ run : pixi run docs-notebooks
129
100
130
101
# Create the mkdocs.yml configuration file
131
102
# The file is created by merging two files:
132
103
# - assets-docs/mkdocs.yml - the common configuration (theme, plugins, etc.)
133
104
# - docs/mkdocs.yml - the project-specific configuration (project name, TOC, etc.)
134
105
- name : Create mkdocs.yml file
135
- run : python tools/create_mkdocs-yml.py
106
+ run : pixi run docs-config
136
107
137
108
# Build the static files
138
109
# Input: docs/ directory containing the Markdown files
139
110
# Output: site/ directory containing the generated HTML files
140
111
- name : Build site with MkDocs
141
- run : |
142
- export JUPYTER_PLATFORM_DIRS=1
143
- export PYTHONWARNINGS="ignore::RuntimeWarning"
144
- export PYTHONPATH="$(pwd)/src${PYTHONPATH:+:$PYTHONPATH}"
145
- mkdocs build
112
+ run : pixi run docs-build
146
113
147
114
# Set up the Pages action to configure the static files to be deployed
148
115
# NOTE: The repository must have GitHub Pages enabled and configured to build using GitHub Actions
@@ -155,17 +122,15 @@ jobs:
155
122
# This artifact is named github-pages and is a single gzip archive containing a single tar file
156
123
# The artifact is then used in the next job by actions/deploy-pages to deploy the static files to GitHub Pages
157
124
# Unfortunately, the artifact is not available for download, so extra steps below are needed to do similar things
158
- - name :
159
- Upload built site as artifact for easyscience.github.io/${{
160
- github.event.repository.name }} (all branches)
125
+ - name : Upload built site as artifact for DEV deployment (all branches)
161
126
uses : actions/upload-pages-artifact@v3
162
127
with :
163
128
path : site/
164
129
165
130
# Upload the static files from the site/ directory to be used in the next job
166
131
# This artifact is only uploaded on tagged releases (tags starting with 'v', e.g., v1.0.3)
167
132
# and is used to push content to gh_pages for custom domain deployment.
168
- - name : Upload built site as artifact for gh_pages (tagged release)
133
+ - name : Upload built site as artifact for PROD deployment (tagged release)
169
134
if : startsWith(github.ref, 'refs/tags/v')
170
135
uses : actions/upload-artifact@v4
171
136
with :
@@ -203,11 +168,14 @@ jobs:
203
168
# restrictions on the branch name need to be set for desired branches on
204
169
# https://github.com/easyscience/diffraction-lib/settings/environments
205
170
# Deployed pages are available at https://easyscience.github.io/diffraction-lib
206
- - name :
207
- Deploy to easyscience.github.io/${{ github.event.repository.name }}
208
- (all branches)
171
+ - name : DEV deployment (all branches)
209
172
uses : actions/deploy-pages@v4
210
173
174
+ - name : Show DEV deployment url (all branches)
175
+ run :
176
+ echo "🔗 DEV deployment url [${{ env.DEV_DEPLOYMENT_URL }}](${{
177
+ env.DEV_DEPLOYMENT_URL }})" >> $GITHUB_STEP_SUMMARY
178
+
211
179
# Download built site as artifact from a previous job for gh_pages (tagged release)
212
180
# This artifact is only downloaded on tagged releases (tags starting with 'v', e.g., v1.0.3)
213
181
# and is used to push content to gh_pages for custom domain deployment.
@@ -228,13 +196,17 @@ jobs:
228
196
# Then the gh_pages branch is used to deploy the site to the custom domain.
229
197
# Deploying is done with a webhook added via:
230
198
# https://github.com/easyscience/diffraction-lib/settings/hooks
231
- - name :
232
- Deploy to gh_pages branch to trigger deployment to custom domain
233
- (tagged release)
199
+ - name : PROD deployment to gh_pages for custom domain (tagged release)
234
200
if : startsWith(github.ref, 'refs/tags/v')
235
201
uses : s0/git-publish-subdir-action@develop
236
202
env :
237
203
GITHUB_TOKEN : ${{ secrets.GH_API_PERSONAL_ACCSESS_TOKEN }}
238
204
REPO : self
239
205
BRANCH : gh_pages
240
206
FOLDER : site
207
+
208
+ - name : Show PROD deployment url (tagged release)
209
+ if : startsWith(github.ref, 'refs/tags/v')
210
+ run :
211
+ echo "🔗 PROD deployment url [${{ env.PROD_DEPLOYMENT_URL }}](${{
212
+ env.PROD_DEPLOYMENT_URL }})" >> $GITHUB_STEP_SUMMARY
0 commit comments