|
| 1 | +# SPDX-License-Identifier: MPL-2.0 |
| 2 | +# GitHub Pages via casket-ssg (hyperpolymath's pure-Haskell static site generator). |
| 3 | +# Replaces the orphan one-off Pages deployment with a reproducible build. |
| 4 | +name: GitHub Pages |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + pages: write |
| 14 | + id-token: write |
| 15 | + |
| 16 | +# Serialise Pages deploys; never cancel an in-flight deploy. |
| 17 | +concurrency: |
| 18 | + group: "pages" |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + timeout-minutes: 20 |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 28 | + |
| 29 | + - name: Checkout casket-ssg |
| 30 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 31 | + with: |
| 32 | + repository: hyperpolymath/casket-ssg |
| 33 | + path: .casket-ssg |
| 34 | + |
| 35 | + - name: Setup GHCup |
| 36 | + uses: haskell-actions/setup@cd0d9bdd65b20557f41bea4dbe43d0b5fbbfe553 # v2.11.0 |
| 37 | + with: |
| 38 | + ghc-version: '9.8.2' |
| 39 | + cabal-version: '3.10' |
| 40 | + |
| 41 | + - name: Cache Cabal |
| 42 | + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v4 |
| 43 | + with: |
| 44 | + path: | |
| 45 | + ~/.cabal/packages |
| 46 | + ~/.cabal/store |
| 47 | + .casket-ssg/dist-newstyle |
| 48 | + key: ${{ runner.os }}-casket-${{ hashFiles('.casket-ssg/casket-ssg.cabal') }} |
| 49 | + |
| 50 | + - name: Build casket-ssg |
| 51 | + working-directory: .casket-ssg |
| 52 | + run: cabal build |
| 53 | + |
| 54 | + - name: Build site |
| 55 | + run: | |
| 56 | + mkdir -p site _site |
| 57 | + # Seed site/index.md from README if the author hasn't provided one. |
| 58 | + if [ ! -f site/index.md ]; then |
| 59 | + { |
| 60 | + echo "---" |
| 61 | + echo "title: $(basename "$PWD")" |
| 62 | + echo "date: $(date +%Y-%m-%d)" |
| 63 | + echo "---" |
| 64 | + if [ -f README.adoc ]; then cat README.adoc |
| 65 | + elif [ -f README.md ]; then cat README.md |
| 66 | + else printf '\n# %s\n\nDocumentation coming soon.\n' "$(basename "$PWD")" |
| 67 | + fi |
| 68 | + } > site/index.md |
| 69 | + fi |
| 70 | + cd .casket-ssg && cabal run casket-ssg -- build ../site ../_site |
| 71 | +
|
| 72 | + - name: Setup Pages |
| 73 | + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 |
| 74 | + |
| 75 | + - name: Upload artifact |
| 76 | + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v3 |
| 77 | + with: |
| 78 | + path: '_site' |
| 79 | + |
| 80 | + deploy: |
| 81 | + timeout-minutes: 20 |
| 82 | + environment: |
| 83 | + name: github-pages |
| 84 | + url: ${{ steps.deployment.outputs.page_url }} |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: build |
| 87 | + steps: |
| 88 | + - name: Deploy to GitHub Pages |
| 89 | + id: deployment |
| 90 | + uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 |
0 commit comments