|
15 | 15 | steps: |
16 | 16 | - name: Check out repository |
17 | 17 | uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 # need history for diffing against main |
| 20 | + |
| 21 | + - name: Download previous Pages artifact (optional cache) |
| 22 | + if: github.event_name == 'push' |
| 23 | + env: |
| 24 | + GH_TOKEN: ${{ github.token }} |
| 25 | + REPO: ${{ github.repository }} |
| 26 | + run: | |
| 27 | + set -euo pipefail |
| 28 | + mkdir -p site/_site |
| 29 | + latest_run=$(gh api "/repos/$REPO/actions/workflows/render-and-publish.yml/runs?branch=main&status=success&per_page=1" --jq '.workflow_runs[0].id' || true) |
| 30 | + if [ -z "${latest_run:-}" ]; then |
| 31 | + echo "No successful main run found; skipping artifact download." |
| 32 | + exit 0 |
| 33 | + fi |
| 34 | + artifact_id=$(gh api "/repos/$REPO/actions/runs/$latest_run/artifacts" --jq '.artifacts[] | select(.name=="github-pages") | .id' | head -n1 || true) |
| 35 | + if [ -z "${artifact_id:-}" ]; then |
| 36 | + echo "No github-pages artifact found on latest main run; skipping download." |
| 37 | + exit 0 |
| 38 | + fi |
| 39 | + echo "Downloading Pages artifact from run $latest_run (artifact $artifact_id)." |
| 40 | + gh api "/repos/$REPO/actions/artifacts/$artifact_id/zip" > /tmp/pages.zip |
| 41 | + unzip -q /tmp/pages.zip -d site/_site |
| 42 | + echo "Contents of site/_site after artifact unzip:" |
| 43 | + ls -la site/_site | head -50 |
18 | 44 |
|
19 | 45 | - name: Set up Python |
20 | 46 | uses: actions/setup-python@v5 |
|
45 | 71 | key: cljdeps-${{ hashFiles('deps.edn') }} |
46 | 72 | restore-keys: cljdeps- |
47 | 73 |
|
48 | | - - name: Build the content notebooks |
49 | | - run: clojure -M:clay -A:markdown |
| 74 | + - name: Detect changed Clojure sources |
| 75 | + if: github.event_name == 'push' |
| 76 | + id: changed_clj |
| 77 | + run: | |
| 78 | + set -euo pipefail |
| 79 | + git fetch origin main:refs/remotes/origin/main |
| 80 | + changed=$(git diff --name-only --diff-filter=ACMR origin/main...HEAD -- 'src/**/*.clj' | tr '\n' ' ') |
| 81 | + if [ -z "$changed" ]; then |
| 82 | + echo "No changed Clojure sources detected." |
| 83 | + echo "files=" >> "$GITHUB_OUTPUT" |
| 84 | + exit 0 |
| 85 | + fi |
| 86 | + echo "Changed Clojure source files:" $changed |
| 87 | + # space-separated for easy reuse |
| 88 | + echo "files=$changed" >> "$GITHUB_OUTPUT" |
| 89 | +
|
| 90 | + - name: Build notebooks (changed set or full when none) |
| 91 | + run: clojure -M:clay -A:markdown ${{ steps.changed_clj.outputs.files }} |
50 | 92 |
|
51 | 93 | - name: Set up Quarto |
52 | 94 | uses: quarto-dev/quarto-actions/setup@v2 |
|
0 commit comments