# Custom Pages build: compiles Thor from source via the Nix flake, uses it to # generate thor/site/, and publishes the result. Replaces the default Jekyll build. name: Deploy site to GitHub Pages on: push: branches: [main] # Only rebuild when something that affects the output changes. paths: - "site/**" - "**/*.odin" - "defaults/**" - "flake.nix" - "flake.lock" - ".github/workflows/pages.yml" workflow_dispatch: permissions: contents: read pages: write id-token: write # Allow one concurrent deployment; don't cancel an in-progress publish. concurrency: group: pages cancel-in-progress: false jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Install Nix uses: cachix/install-nix-action@v30 with: extra_nix_config: | experimental-features = nix-command flakes # Free cache: snapshots /nix/store into GitHub's Actions cache. The key is # hashed over the inputs that change Thor's output, so a site-content-only # change is a full hit (Thor not recompiled), while an Odin source change # restores the nearest store and rebuilds just the delta. - name: Cache /nix/store uses: nix-community/cache-nix-action@v6 with: primary-key: nix-${{ runner.os }}-${{ hashFiles('flake.lock', '**/*.nix', '**/*.odin') }} restore-prefixes-first-match: nix-${{ runner.os }}- gc-max-store-size-linux: 2G purge: true purge-prefixes: nix-${{ runner.os }}- purge-created: 604800 # drop entries older than 7 days # First run compiles Thor + the tree-sitter grammar libs; later runs # restore them from the cache above and skip the compile. - name: Build Thor run: nix build .#default --print-build-logs - name: Generate site working-directory: site run: ../result/bin/thor -base-url=https://sbrow.github.io/thor -minify - name: Upload Pages artifact uses: actions/upload-pages-artifact@v3 with: path: site/public deploy: needs: build runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4