|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +name: GitHub Pages |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pages: write |
| 12 | + id-token: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: "pages" |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 24 | + |
| 25 | + - name: Checkout casket-ssg |
| 26 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 |
| 27 | + with: |
| 28 | + repository: hyperpolymath/casket-ssg |
| 29 | + path: .casket-ssg |
| 30 | + |
| 31 | + - name: Setup GHCup |
| 32 | + uses: haskell-actions/setup@ec49483bfc012387b227434aba94f59a6ecd0900 # v2 |
| 33 | + with: |
| 34 | + ghc-version: '9.8.2' |
| 35 | + cabal-version: '3.10' |
| 36 | + |
| 37 | + - name: Cache Cabal |
| 38 | + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 |
| 39 | + with: |
| 40 | + path: | |
| 41 | + ~/.cabal/packages |
| 42 | + ~/.cabal/store |
| 43 | + .casket-ssg/dist-newstyle |
| 44 | + key: ${{ runner.os }}-casket-${{ hashFiles('.casket-ssg/casket-ssg.cabal') }} |
| 45 | + |
| 46 | + - name: Build casket-ssg |
| 47 | + working-directory: .casket-ssg |
| 48 | + run: cabal build |
| 49 | + |
| 50 | + - name: Build site |
| 51 | + run: | |
| 52 | + mkdir -p site _site |
| 53 | + # Generate index.md from README if site/index.md doesn't exist |
| 54 | + if [ ! -f site/index.md ]; then |
| 55 | + if [ -f README.adoc ]; then |
| 56 | + # Convert AsciiDoc to Markdown (basic conversion) |
| 57 | + echo "---" > site/index.md |
| 58 | + echo "title: $(basename $PWD)" >> site/index.md |
| 59 | + echo "date: $(date +%Y-%m-%d)" >> site/index.md |
| 60 | + echo "---" >> site/index.md |
| 61 | + cat README.adoc >> site/index.md |
| 62 | + elif [ -f README.md ]; then |
| 63 | + echo "---" > site/index.md |
| 64 | + echo "title: $(basename $PWD)" >> site/index.md |
| 65 | + echo "date: $(date +%Y-%m-%d)" >> site/index.md |
| 66 | + echo "---" >> site/index.md |
| 67 | + cat README.md >> site/index.md |
| 68 | + else |
| 69 | + echo "---" > site/index.md |
| 70 | + echo "title: $(basename $PWD)" >> site/index.md |
| 71 | + echo "date: $(date +%Y-%m-%d)" >> site/index.md |
| 72 | + echo "---" >> site/index.md |
| 73 | + echo "" >> site/index.md |
| 74 | + echo "# $(basename $PWD)" >> site/index.md |
| 75 | + echo "" >> site/index.md |
| 76 | + echo "Documentation coming soon." >> site/index.md |
| 77 | + fi |
| 78 | + fi |
| 79 | + cd .casket-ssg && cabal run casket-ssg -- build ../site ../_site |
| 80 | +
|
| 81 | + - name: Setup Pages |
| 82 | + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 |
| 83 | + |
| 84 | + - name: Upload artifact |
| 85 | + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 |
| 86 | + with: |
| 87 | + path: '_site' |
| 88 | + |
| 89 | + deploy: |
| 90 | + environment: |
| 91 | + name: github-pages |
| 92 | + url: ${{ steps.deployment.outputs.page_url }} |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: build |
| 95 | + steps: |
| 96 | + - name: Deploy to GitHub Pages |
| 97 | + id: deployment |
| 98 | + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |
0 commit comments