Improve caching in book workflow #89
Workflow file for this run
This file contains hidden or 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: deploy-book | |
| # Only run this when the master branch changes | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| # This job installs dependencies, build the book, and pushes it to `gh-pages` | |
| jobs: | |
| deploy-book: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare apt cache directories | |
| run: | | |
| sudo mkdir -p /var/lib/apt/lists/partial /var/cache/apt/archives/partial | |
| sudo chown -R "$USER" /var/lib/apt/lists /var/cache/apt/archives | |
| - name: Cache apt packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| /var/lib/apt/lists | |
| /var/cache/apt/archives | |
| key: ${{ runner.os }}-apt-v1 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends \ | |
| curl \ | |
| bzip2 \ | |
| ca-certificates \ | |
| dvipng \ | |
| texlive-fonts-recommended \ | |
| texlive-fonts-extra \ | |
| texlive-latex-extra \ | |
| cm-super | |
| - name: Restore apt cache permissions | |
| if: always() | |
| run: sudo chown -R "$USER" /var/lib/apt/lists /var/cache/apt/archives | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 200 | |
| fetch-tags: true | |
| ref: ${{ github.ref }} | |
| - uses: prefix-dev/[email protected] | |
| with: | |
| pixi-version: v0.55.0 | |
| run-install: false | |
| - run: pixi lock --check | |
| - name: Install project environment | |
| run: pixi install --locked | |
| - name: Cache tutorial data | |
| id: cache-tutorial-data | |
| uses: actions/cache@v4 | |
| with: | |
| path: data/dwi_full_brainmask.h5 | |
| key: ${{ runner.os }}-tutorial-data-v1 | |
| - name: Download tutorial data | |
| if: steps.cache-tutorial-data.outputs.cache-hit != 'true' | |
| run: | | |
| set -xeuo pipefail | |
| data_dir="${{ github.workspace }}/data" | |
| data_file="$data_dir/dwi_full_brainmask.h5" | |
| mkdir -p "$data_dir" | |
| curl -L \ | |
| https://files.osf.io/v1/resources/8k95s/providers/osfstorage/68e5464a451cf9cf1fc51a53 \ | |
| --output "$data_file" | |
| test -s "$data_file" | |
| - name: Configure tutorial data | |
| run: | | |
| data_file="${{ github.workspace }}/data/dwi_full_brainmask.h5" | |
| test -s "$data_file" | |
| echo "NIPREPS_TUTORIAL_DATA=$data_file" >> "$GITHUB_ENV" | |
| # Build the page | |
| - name: Build the book | |
| run: pixi run build-book | |
| # Push the book's HTML to github-pages | |
| - name: GitHub Pages action | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs/_build/html |