|
| 1 | +name: Deploy book with Python, SPARQL, and R |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Update Metadata"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +# This job installs dependencies, builds the book, and deploys it to GitHub Pages |
| 12 | +# only runs if "Update Metadata" workflow is successful |
| 13 | +jobs: |
| 14 | + deploy-book: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + pages: write |
| 18 | + id-token: write |
| 19 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + # Python |
| 25 | + - name: Set up Python 3.11 |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version: 3.11 |
| 29 | + cache: pip |
| 30 | + |
| 31 | + - name: Install Python dependencies |
| 32 | + run: | |
| 33 | + pip install -r requirements.txt |
| 34 | + |
| 35 | + |
| 36 | + # R |
| 37 | + - name: Set up R |
| 38 | + uses: r-lib/actions/setup-r@v2 |
| 39 | + |
| 40 | + - name: Install R dependencies |
| 41 | + uses: r-lib/actions/setup-r-dependencies@v2 |
| 42 | + with: |
| 43 | + cache: true |
| 44 | + cache-version: 2 |
| 45 | + packages: | |
| 46 | + any::tidyverse |
| 47 | + any::IRkernel |
| 48 | + install-pandoc: false |
| 49 | + install-quarto: false |
| 50 | + |
| 51 | + - name: Set up IRkernel |
| 52 | + run: | |
| 53 | + IRkernel::installspec(name="ir", displayname="R") |
| 54 | + shell: Rscript {0} |
| 55 | + |
| 56 | + |
| 57 | + # SPARQL |
| 58 | + - name: Install SPARQL kernel |
| 59 | + run: | |
| 60 | + jupyter sparqlkernel install --user |
| 61 | + |
| 62 | + |
| 63 | + # check all kernels |
| 64 | + - name: Log all available kernels |
| 65 | + run: | |
| 66 | + jupyter kernelspec list |
| 67 | +
|
| 68 | + # only caches if set up in _config.yml with: |
| 69 | + # execute: |
| 70 | + # execute_notebooks: cache |
| 71 | + - name: Cache executed notebooks |
| 72 | + uses: actions/cache@v3 |
| 73 | + with: |
| 74 | + path: _build/.jupyter_cache |
| 75 | + key: jupyter-book-cache-${{ hashFiles('requirements.txt') }} |
| 76 | + |
| 77 | + - name: Build the book |
| 78 | + run: | |
| 79 | + jupyter-book build . |
| 80 | +
|
| 81 | + - name: Upload book artifact |
| 82 | + uses: actions/upload-pages-artifact@v3 |
| 83 | + with: |
| 84 | + path: "_build/html" |
| 85 | + |
| 86 | + - name: Deploy to GitHub Pages |
| 87 | + id: deployment |
| 88 | + uses: actions/deploy-pages@v4 |
0 commit comments