|
| 1 | +name: CI |
| 2 | +on: |
| 3 | + push: |
| 4 | + # Only on branches, not tags/releases |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - '*' |
| 10 | + |
| 11 | +concurrency: |
| 12 | + # Skip intermediate builds: always. |
| 13 | + # Cancel intermediate builds: only if it is a pull request build. |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout this repository |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Install Julia |
| 25 | + uses: julia-actions/setup-julia@v1 |
| 26 | + with: |
| 27 | + version: "1" # This will automatically pick the latest Julia version |
| 28 | + |
| 29 | + - name: Cache Julia artifacts & such |
| 30 | + uses: julia-actions/cache@v1 |
| 31 | + with: |
| 32 | + cache-registries: "true" |
| 33 | + |
| 34 | + # We set up a folder that Pluto can use to cache exported |
| 35 | + # notebooks. If the notebook file did not change, then Pluto can |
| 36 | + # take the exported file from cache instead of running the |
| 37 | + # notebook. |
| 38 | + - name: Set up notebook state cache |
| 39 | + uses: actions/cache@v3 |
| 40 | + with: |
| 41 | + path: pluto_state_cache |
| 42 | + key: ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }}-${{ hashFiles('**/*jl') }} |
| 43 | + restore-keys: | |
| 44 | + ${{ runner.os }}-pluto_state_cache-v2-${{ hashFiles('**/Project.toml', '**/Manifest.toml', '.github/workflows/*' ) }} |
| 45 | +
|
| 46 | +
|
| 47 | + - name: Run & export Pluto notebooks |
| 48 | + run: | |
| 49 | + julia -e 'using Pkg |
| 50 | + Pkg.activate(mktempdir()) |
| 51 | + Pkg.add([ |
| 52 | + Pkg.PackageSpec(name="PlutoPDF", version="1.2.1"), |
| 53 | + Pkg.PackageSpec(name="PlutoSliderServer", version="1"), |
| 54 | + ]) |
| 55 | +
|
| 56 | + import PlutoPDF |
| 57 | + import PlutoSliderServer |
| 58 | +
|
| 59 | + PlutoSliderServer.github_action("src/."; |
| 60 | + Export_cache_dir="pluto_state_cache", |
| 61 | + Export_baked_notebookfile=false, |
| 62 | + Export_baked_state=false, |
| 63 | + # more parameters can go here |
| 64 | + ) |
| 65 | +
|
| 66 | + notebooks = PlutoSliderServer.find_notebook_files_recursive("src") |
| 67 | + for notebook in notebooks |
| 68 | + file = joinpath("src", notebook) |
| 69 | + println("Converting $file to PDF...") |
| 70 | + PlutoPDF.pluto_to_pdf(file; open=false) |
| 71 | + end |
| 72 | + ' |
0 commit comments