|
| 1 | +name: Export Pluto notebooks |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +# When two jobs run in parallel, cancel the older ones, to make sure that the website is generated from the most recent commit. |
| 10 | +concurrency: |
| 11 | + group: pluto-export |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +# This action needs permission to write the exported HTML file to the gh-pages branch. |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + # (all other permission fields default to "none") |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-deploy: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + steps: |
| 23 | + - name: Checkout this repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install Julia |
| 27 | + uses: julia-actions/setup-julia@v2 |
| 28 | + with: |
| 29 | + version: "1" # This will automatically pick the latest Julia version |
| 30 | + |
| 31 | + - name: Cache Julia artifacts & such |
| 32 | + uses: julia-actions/cache@v2 |
| 33 | + with: |
| 34 | + cache-registries: "true" |
| 35 | + |
| 36 | + # We set up a folder that Pluto can use to cache exported notebooks. If the notebook file did not change, then Pluto can take the exported file from cache instead of running the notebook. |
| 37 | + - name: Set up notebook state cache |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: pluto_state_cache |
| 41 | + key: ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }}-${{ hashFiles('**/*jl') }} |
| 42 | + restore-keys: | |
| 43 | + ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }} |
| 44 | +
|
| 45 | +
|
| 46 | + - name: Run & export Pluto notebooks |
| 47 | + run: | |
| 48 | + julia -e 'using Pkg |
| 49 | + Pkg.activate(mktempdir()) |
| 50 | + Pkg.add([ |
| 51 | + Pkg.PackageSpec(name="PlutoSliderServer", version="0.3.2-0.3"), |
| 52 | + ]) |
| 53 | +
|
| 54 | + import PlutoSliderServer |
| 55 | +
|
| 56 | + PlutoSliderServer.github_action("."; |
| 57 | + Export_cache_dir="pluto_state_cache", |
| 58 | + Export_baked_notebookfile=false, |
| 59 | + Export_baked_state=false, |
| 60 | + # more parameters can go here |
| 61 | + )' |
| 62 | +
|
| 63 | +
|
| 64 | + - name: Deploy to gh-pages |
| 65 | + uses: JamesIves/github-pages-deploy-action@releases/v4 |
| 66 | + with: |
| 67 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + branch: gh-pages |
| 69 | + folder: . |
| 70 | + single-commit: true |
0 commit comments