Skip to content

Enable persistent storage #233

Enable persistent storage

Enable persistent storage #233

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- main
release:
branch: main
types: [released]
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12.1'
- name: Setup micromamba
uses: mamba-org/setup-micromamba@v2
- name: Install the dependencies
run: |
python -m pip install -r requirements.txt
- name: Check the Pyodide version
run: |
echo "PYODIDE_SHA_SHORT=$(git submodule status pyodide | cut -c 2-8)" >> $GITHUB_ENV
- name: Cache the Pyodide build
uses: actions/cache@v4
with:
path: ./pyodide
key: pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
restore-keys: |
pyodide-${{ github.ref }}-${{ env.PYODIDE_SHA_SHORT }}
pyodide-${{ github.ref }}
pyodide-refs/heads/main
- name: Ensure Pyodide source files are fresh
run: |
cd pyodide
git status
git diff --name-only | xargs git checkout --
- name: Cache the Pyodide Docker image
uses: ScribeMD/[email protected]
with:
key: docker-pyodide-${{ hashFiles('pyodide/Dockerfile') }}
- name: Discover the cached Pyodide Docker image
run: echo "PYODIDE_DOCKER_IMAGE=$(docker images climet-eu/pyodide --format '{{.ID}}')" >> $GITHUB_ENV
- name: Build the Pyodide Docker image
if: ${{ env.PYODIDE_DOCKER_IMAGE == '' }}
run: |
cd pyodide
docker build -t climet-eu/pyodide .
echo "PYODIDE_DOCKER_IMAGE=$(docker build . -q)" >> $GITHUB_ENV
- name: Build Pyodide and all required packages
run: |
cd pyodide
./run_docker \
--non-interactive \
PYODIDE_PACKAGES="aiohttp,basemap,cdsapi,cfgrib,cf-units,cmcrameri,dask,earthkit,ecmwf-api-client,ecmwf-opendata,field-compression-benchmark,fsspec,git2,gribscan,h5netcdf,intake,ipyfilite,ipython,kerchunk,lzma,matplotlib,MetPy,netcdf4,numcodecs,numpy,pandas,pint,requests,scipy,sympy,s3fs,xarray,xeofs,zarr" \
make
- name: Extract the requirements.txt file
continue-on-error: ${{ github.event_name != 'release' }}
run: python tools/requirements.py
- name: Clean up the pyodide build
run: |
cd pyodide
find . -name jupyter-lite.json -delete
find . -name jupyter_lite_config.json -delete
mkdir -p packages/numpy/build
touch packages/numpy/build/ls-success
ls -d packages/*/build/* | xargs rm -r
- name: Check the validity of the requirements.txt file
continue-on-error: ${{ github.event_name != 'release' }}
run: |
python -m venv venv
source venv/bin/activate
python -m pip install -r files/requirements.txt --dry-run --ignore-installed
deactivate
rm -rf venv
- name: Build the JupyterLite site
run: |
rm -f files/README.md && cp ./README.md files/
mkdir -p static
cp -r pyodide/dist static/pyodide
rm -rf static/pyodide/*-tests.tar
rm -f static/pyodide/tsconfig.tsbuildinfo
jupyter lite build --output-dir staging
cp ./_headers staging/
cp static/favicons/favicon.ico staging/
find staging/ -name favicon.ico | xargs -L1 cp -f static/favicons/favicon.ico
rm -rf static
- name: Get the current branch name
uses: tj-actions/branch-names@v8
id: branch
- name: Compute the current version name
run: echo "VERSION=${{ steps.branch.outputs.current_branch || steps.branch.outputs.tag }}" >> $GITHUB_ENV
- name: Checkout the previous dist branch
uses: actions/checkout@v4
with:
ref: dist
path: dist
continue-on-error: ${{ github.event_name != 'release' }}
- name: Merge the different dist versions
run: |
mkdir -p dist
rm -rf dist/${{ env.VERSION }}
mv staging dist/${{ env.VERSION }}
- name: Deploy to dist branch
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: dist
publish_dir: ./dist
keep_files: false
force_orphan: true