Publish #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Publish | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 5 * * 1' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
name: Build Jupyter Notebooks and HTML | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup GitHub Pages | |
uses: actions/configure-pages@v5 | |
- name: Setup pixi | |
uses: prefix-dev/[email protected] | |
with: | |
cache: true | |
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
- name: Build executed notebooks and HTML | |
run: pixi run build | |
- name: Upload executed notebooks as GitHub artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: executed-notebooks | |
path: build/jupyter_execute/ | |
if-no-files-found: error | |
- name: Prepare for Jupyter Lite | |
run: | | |
cp README.md docs/ | |
# Convert Jupytext to ipynb format. | |
pixi run ./convert_all.sh ipynb | |
- name: Build Jupyter Lite | |
run: pixi run -e jupyterlite jupyter lite build --contents docs/ --output-dir build/html/jupyterlite | |
- name: Upload HTML as GitHub artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: build/html | |
deploy-gh-pages: | |
name: Deploy HTML to GitHub Pages | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Deploy HTML to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
deploy-notebooks: | |
name: Push to 'notebooks' branch ipynb-formatted version | |
# Sets permissions of the GITHUB_TOKEN to allow pushing to 'notebooks' branch | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup pixi | |
uses: prefix-dev/[email protected] | |
- name: Publish ipynb-formatted variant to 'notebooks' branch of this repo | |
run: | | |
git fetch origin | |
git checkout -B notebooks | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
pixi run ./convert_all.sh ipynb | |
git add . | |
git commit -am "Convert jupytext to ipynb format" | |
git push origin notebooks --force-with-lease |