Skip to content

Commit dcecb18

Browse files
authored
Merge pull request #145 from brian-rose/myst
Add MyST compatibility
2 parents fcd4474 + 1f50fbf commit dcecb18

File tree

2 files changed

+24
-44
lines changed

2 files changed

+24
-44
lines changed

.github/workflows/build-book.yaml

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
environment_name:
7-
description: 'Name of conda environment to activate'
7+
description: 'Name of conda environment to activate (NO LONGER USED)'
88
required: false
99
default: 'cookbook-dev'
1010
type: string
@@ -16,13 +16,8 @@ on:
1616
path_to_notebooks:
1717
description: 'Location of the JupyterBook source relative to repo root'
1818
required: false
19-
default: './'
19+
default: '.'
2020
type: string
21-
use_cached_environment:
22-
description: 'Flag for whether we should attempt to retrieve a previously cached environment.'
23-
required: false
24-
default: 'true'
25-
type: string # had a lot of trouble with boolean types, see https://github.com/actions/runner/issues/1483${{ github.repository }}
2621
artifact_name:
2722
description: 'The name to assign to the built book artifact.'
2823
required: false
@@ -58,7 +53,11 @@ on:
5853
required: false
5954
default: success
6055
type: string
61-
56+
base_url:
57+
description: 'Determines where the website is served from, including CSS & JS assets (needed for MyST)'
58+
required: false
59+
default: '/${{ github.event.repository.name }}'
60+
type: string
6261

6362
secrets:
6463
ARM_USERNAME:
@@ -80,12 +79,16 @@ on:
8079
description: 'NASA Earthdata API Password'
8180
required: false
8281

82+
env:
83+
# the BASE_URL environment variable needs to be set if building with myst
84+
BASE_URL: ${{ inputs.base_url }}
85+
8386
jobs:
8487
build:
8588
runs-on: ubuntu-latest
8689
defaults:
8790
run:
88-
shell: bash -l {0}
91+
shell: bash -leo pipefail {0}
8992
steps:
9093
- name: Checkout the code from the repo
9194
if: inputs.build_from_code_artifact == 'false'
@@ -108,10 +111,11 @@ jobs:
108111
run: |
109112
unzip pr_code.zip
110113
rm -f pr_code.zip
111-
112-
# - name: Fetch Repo Name
113-
# id: repo-name
114-
# run: echo "value=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT # just the repo name, not owner
114+
115+
- name: Setup Node.js
116+
uses: actions/setup-node@v4
117+
with:
118+
node-version: 18.x
115119

116120
- name: Get GitHub environment variables
117121
id: get-env
@@ -150,26 +154,11 @@ jobs:
150154
run: |
151155
echo '(DEBUG) The value of steps.env_change.outputs.any_changed is:'
152156
echo ${{ steps.env_change.outputs.any_changed }}
153-
154-
- name: Setup Miniforge
155-
uses: conda-incubator/setup-miniconda@v3
156-
with:
157-
miniforge-version: latest
158-
python-version: "3.10" # binderbot is failing with python 3.11
159-
activate-environment: ${{ inputs.environment_name }}
160-
161-
- name: Set cache date
162-
if: inputs.use_cached_environment == 'true'
163-
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
164-
165-
- uses: actions/cache@v4
166-
if: inputs.use_cached_environment == 'true'
157+
158+
- name: Setup environment with micromamba
159+
uses: mamba-org/setup-micromamba@v2
167160
with:
168-
path: /usr/share/miniconda3/envs/${{ inputs.environment_name }}
169-
# This should create a key that looks like 'linux-64-conda-environment.yml-[HASH]-_config.yml-[HASH]-DATE'
170-
# Logic inspired by https://dev.to/epassaro/caching-anaconda-environments-on-github-actions-2d08
171-
key: ${{ format('linux-64-conda-{0}-{1}-{2}-{3}-{4}', inputs.environment_file, hashFiles(format('{0}', inputs.environment_file)), '_config.yml', hashFiles(format('{0}', '_config.yml')), env.DATE )}}
172-
id: cache
161+
environment-file: ${{ inputs.environment_file }}
173162

174163
- name: Create book build environment
175164
if: |
@@ -182,16 +171,6 @@ jobs:
182171
pip install git+https://github.com/pangeo-gallery/binderbot.git
183172
conda list
184173
185-
- name: Update execution environment
186-
if: |
187-
(inputs.use_cached_environment != 'true'
188-
|| steps.cache.outputs.cache-hit != 'true'
189-
|| steps.env_change.outputs.any_changed == 'true')
190-
&& steps.parse_config.outputs.execute_notebooks != 'binder'
191-
run: |
192-
conda env update -n ${{ inputs.environment_name }} -f ${{ inputs.environment_file }}
193-
conda list
194-
195174
- name: Get paths to notebook files
196175
if: |
197176
steps.parse_config.outputs.execute_notebooks == 'binder'
@@ -258,6 +237,7 @@ jobs:
258237
- name: Build the book
259238
# Assumption is that if execute_notebooks != 'binder' then the _config.yml file must be set to execute notebooks during build
260239
env:
240+
# BASE_URL: /${{ github.repository }}
261241
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
262242
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}
263243
AQS_USERNAME: ${{ secrets.AQS_USERNAME }}
@@ -276,7 +256,7 @@ jobs:
276256
if [ -f book.zip ]; then
277257
rm -rf book.zip
278258
fi
279-
zip -r book.zip ${{ inputs.path_to_notebooks }}/ ${{ inputs.output_path }}
259+
zip -r book.zip ${{ inputs.path_to_notebooks }}/${{ inputs.output_path }}
280260
281261
- name: Upload zipped book artifact
282262
uses: actions/upload-artifact@v4

.github/workflows/deploy-book.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ jobs:
6666
folder: ${{ inputs.publish_dir }}
6767
clean: true
6868
clean-exclude: _preview/* # keep existing previews from other PRs
69-
target-folder: ${{ inputs.destination_dir }}
69+
target-folder: ${{ inputs.destination_dir }}

0 commit comments

Comments
 (0)