1- name : Building and deploying docs
1+ name : Build and deploy docs
22
33on :
44 # Trigger the workflow on push
55 push :
6- # To the develop and master branches
7- branches : [develop, master, docs, d-spacing]
8-
6+ # Selected branches
7+ branches : [develop, master, docs]
98 # Allows you to run this workflow manually from the Actions tab
109 workflow_dispatch :
1110
11+ # Allow only one concurrent workflow, skipping runs queued between the run
12+ # in-progress and latest queued. And cancel in-progress runs.
13+ concurrency :
14+ group :
15+ ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+ cancel-in-progress : true
17+
1218env :
1319 # Set the environment variables to be used in all jobs defined in this workflow
1420 # Set the CI_BRANCH environment variable to be the branch name
1824
1925jobs :
2026 # Job 1: Build the static files for the documentation site
21- building-docs :
22- runs-on : macos-14 # Use macOS to switch to dark mode for Plotly charts
27+ build-docs :
28+ strategy :
29+ matrix :
30+ os : [macos-14] # Use macOS to switch to dark mode for Plotly charts
31+ python-version : ['3.13']
2332
24- steps :
25- - name : Cancel previous workflow runs
26- uses : n1hility/cancel-previous-runs@v2
27- with :
28- token : ${{ secrets.GITHUB_TOKEN }}
33+ runs-on : ${{ matrix.os }}
2934
35+ steps :
3036 # Without this step, GITHUB_REPOSITORY is not accessible from mkdocs.yml
3137 - name : Get GitHub repository
3238 run : echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY" >> $GITHUB_ENV
3339
34- # Save the latest release version of easyscience/EasyDiffractionLib to RELEASE_VERSION
40+ # Save the latest release version of easyscience/diffraction-lib to RELEASE_VERSION
3541 # RELEASE_VERSION is used in the mkdocs.yml file to set release_version.
3642 # The release_version is then needed to display the latest release version in the index.md file
37- - name : Get the latest release version of EasyDiffraction Library
43+ - name : Get the latest release version of easydiffraction library
3844 run : |
39- git clone --depth 1 https://github.com/easyscience/EasyDiffractionLib .
45+ git clone --depth 1 https://github.com/easyscience/${{ github.event.repository.name }} .
4046 git fetch --tags
4147 echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
4248
@@ -54,18 +60,19 @@ jobs:
5460 - name : Check-out repository
5561 uses : actions/checkout@v4
5662
57- - name : Set up Python environment
63+ - name : Set up Python ${{ matrix.python-version }}
5864 uses : actions/setup-python@v5
5965 with :
60- python-version : ' 3.12 '
66+ python-version : ${{ matrix.python-version }}
6167
6268 - name : Upgrade package installer for Python
69+ shell : bash
6370 run : python -m pip install --upgrade pip
6471
6572 # Install EasyDiffraction Library to run Jupyter notebooks
66- # Install with the 'charts ' and 'docs ' extras
73+ # Install with the 'docs ' and 'visualization ' extras
6774 - name : Install EasyDiffraction Library and its dependencies
68- run : python -m pip install .
75+ run : python -m pip install .'[dev,docs,visualization]'
6976
7077 # Clone assets extra from:
7178 # - easyscience/assets-docs
@@ -96,19 +103,23 @@ jobs:
96103 cp ../assets-branding/easydiffraction/icons/bw.svg overrides/.icons/easydiffraction.svg
97104 cp ../assets-branding/easyscience-org/icons/eso-icon_bw.svg overrides/.icons/easyscience.svg
98105
99- # Copy Jupyter notebooks from the project to the docs folder
106+ # Convert python scripts in the notebooks directory to Jupyter notebooks
107+ # Strip output from the notebooks and simpify cell ids
100108 # The notebooks are used to generate the documentation
101- - name : Convert ${{ env.NOTEBOOKS_DIR }}/*.py to docs/${{env.NOTEBOOKS_DIR }}/*.ipynb
109+ - name :
110+ Convert ${{ env.NOTEBOOKS_DIR }}/*.py to docs/${{env.NOTEBOOKS_DIR
111+ }}/*.ipynb
102112 run : |
103113 cp -R ${{ env.NOTEBOOKS_DIR }}/data docs/${{ env.NOTEBOOKS_DIR }}/
104114 jupytext ${{ env.NOTEBOOKS_DIR }}/*.py --from py:percent --to ipynb
115+ nbstripout ${{ env.NOTEBOOKS_DIR }}/*.ipynb
105116 mv ${{ env.NOTEBOOKS_DIR }}/*.ipynb docs/${{ env.NOTEBOOKS_DIR }}/
106117
107118 # The following step is needed to avoid the following message during the build:
108119 # "Matplotlib is building the font cache; this may take a moment"
109120 - name : Pre-build site step
110121 run : |
111- export PYTHONPATH=$(pwd)/src: $PYTHONPATH
122+ export PYTHONPATH=" $(pwd)/src${PYTHONPATH:+: $PYTHONPATH}"
112123 python -c "import easydiffraction"
113124
114125 # Create the mkdocs.yml configuration file
@@ -125,7 +136,7 @@ jobs:
125136 run : |
126137 export JUPYTER_PLATFORM_DIRS=1
127138 export PYTHONWARNINGS="ignore::RuntimeWarning"
128- export PYTHONPATH=$(pwd)/src: $PYTHONPATH
139+ export PYTHONPATH=" $(pwd)/src${PYTHONPATH:+: $PYTHONPATH}"
129140 mkdocs build
130141
131142 # Set up the Pages action to configure the static files to be deployed
@@ -140,17 +151,16 @@ jobs:
140151 # The artifact is then used in the next job by actions/deploy-pages to deploy the static files to GitHub Pages
141152 # Unfortunately, the artifact is not available for download, so extra steps below are needed to do similar things
142153 - name :
143- Upload built site as artifact for
144- easyscience. github.io/EasyDiffractionLib (all branches)
154+ Upload built site as artifact for easyscience.github.io/${{
155+ github.event.repository.name }} (all branches)
145156 uses : actions/upload-pages-artifact@v3
146157 with :
147158 path : site/
148159
149160 # Upload the static files from the site/ directory to be used in the next job
150161 # This extra step is needed to allow the download of the artifact in the next job
151162 # for pushing its content to the branch named 'gh_pages'
152- - name :
153- Upload built site as artifact for gh_pages (master branch)
163+ - name : Upload built site as artifact for gh_pages (master branch)
154164 if : ${{ env.CI_BRANCH == 'master' }}
155165 uses : actions/upload-artifact@v4
156166 with :
@@ -160,8 +170,8 @@ jobs:
160170 compression-level : 0
161171
162172 # Job 2: Deploy the static files
163- deploying -docs :
164- needs : building -docs # previous job 'build-docs' need to be finished first
173+ deploy -docs :
174+ needs : build -docs # previous job 'build-docs' need to be finished first
165175
166176 # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
167177 permissions :
@@ -189,7 +199,9 @@ jobs:
189199 # https://github.com/easyscience/diffraction-lib/settings/environments
190200 # Currently, only develop and master branches are allowed to deploy to GitHub Pages
191201 # Deployed pages are available at https://easyscience.github.io/diffraction-lib
192- - name : Deploy to easyscience.github.io/diffraction-lib (all branches)
202+ - name :
203+ Deploy to easyscience.github.io/${{ github.event.repository.name }}
204+ (all branches)
193205 uses : actions/deploy-pages@v4
194206
195207 # Download built site as artifact from a previous job for gh_pages (master branch)
@@ -209,7 +221,8 @@ jobs:
209221 # https://github.com/easyscience/diffraction-lib/settings/hooks
210222 # This is done for the gh_pages branch when the site is tested with a step above
211223 - name :
212- Deploy to gh_pages branch to trigger deployment to custom domain (master branch)
224+ Deploy to gh_pages branch to trigger deployment to custom domain
225+ (master branch)
213226 if : ${{ env.CI_BRANCH == 'master' }}
214227 uses : s0/git-publish-subdir-action@develop
215228 env :
0 commit comments