|
| 1 | +name: Docs |
| 2 | + |
| 3 | +# Only one workflow can run at a time |
| 4 | +# If there is newer workflow in progress, cancel older ones |
| 5 | +concurrency: |
| 6 | + group: docs |
| 7 | + cancel-in-progress: true |
| 8 | + |
| 9 | +# Put 'on' in quotes to avoid YAML parsing error |
| 10 | +"on": |
| 11 | + # Enable manual triggering |
| 12 | + workflow_dispatch: {} |
| 13 | + # Run on commits to main branch |
| 14 | + push: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + # Run only on changes to relevant files |
| 18 | + paths: |
| 19 | + - .github/workflows/docs.yaml |
| 20 | + - docs/** |
| 21 | + - flake.lock |
| 22 | + - "*.nix" |
| 23 | + - Taskfile.dist.yaml |
| 24 | + |
| 25 | +jobs: |
| 26 | + build: |
| 27 | + name: Build docs |
| 28 | + # Pin version of Ubuntu to avoid breaking changes |
| 29 | + runs-on: ubuntu-24.04 |
| 30 | + # Use reasonable timeout to avoid stuck workflows |
| 31 | + timeout-minutes: 10 |
| 32 | + env: |
| 33 | + NIX_CACHE_DIR: /home/runner/.nixcache/ |
| 34 | + permissions: |
| 35 | + # Needed to checkout code |
| 36 | + contents: read |
| 37 | + # Needed to upload page artifact |
| 38 | + pages: write |
| 39 | + steps: |
| 40 | + - name: Checkout code |
| 41 | + |
| 42 | + - name: Setup Nix cache |
| 43 | + |
| 44 | + id: cache-nix |
| 45 | + with: |
| 46 | + path: ${{ env.NIX_CACHE_DIR }} |
| 47 | + key: docs-nix |
| 48 | + - name: Setup docs modules cache |
| 49 | + |
| 50 | + with: |
| 51 | + path: docs/node_modules/ |
| 52 | + key: docs-modules |
| 53 | + - name: Install Nix |
| 54 | + |
| 55 | + with: |
| 56 | + github_access_token: ${{ github.token }} |
| 57 | + install_url: https://releases.nixos.org/nix/nix-2.28.5/install |
| 58 | + # See: https://github.com/cachix/install-nix-action/issues/56 |
| 59 | + - name: Import Nix store cache |
| 60 | + if: steps.cache-nix.outputs.cache-hit == 'true' |
| 61 | + run: > |
| 62 | + nix-store |
| 63 | + --import |
| 64 | + < ${{ env.NIX_CACHE_DIR }}/archive.nar |
| 65 | + - name: Build docs |
| 66 | + run: > |
| 67 | + nix |
| 68 | + develop |
| 69 | + ./#docs |
| 70 | + --command |
| 71 | + -- |
| 72 | + task |
| 73 | + docs |
| 74 | + -- |
| 75 | + build |
| 76 | + --out-dir |
| 77 | + build/ |
| 78 | + - name: Setup Pages |
| 79 | + |
| 80 | + - name: Upload artifact |
| 81 | + |
| 82 | + with: |
| 83 | + path: docs/build/ |
| 84 | + # See: https://github.com/cachix/install-nix-action/issues/56 |
| 85 | + - name: Export Nix store cache |
| 86 | + if: "!cancelled()" |
| 87 | + run: > |
| 88 | + mkdir |
| 89 | + --parents |
| 90 | + ${{ env.NIX_CACHE_DIR }} |
| 91 | + && |
| 92 | + nix-store |
| 93 | + --export $(find /nix/store/ -maxdepth 1 -name '*-*') |
| 94 | + > ${{ env.NIX_CACHE_DIR }}/archive.nar |
| 95 | + deploy: |
| 96 | + name: Deploy docs |
| 97 | + # Run only if build job succeeded |
| 98 | + needs: build |
| 99 | + # Pin version of Ubuntu to avoid breaking changes |
| 100 | + runs-on: ubuntu-24.04 |
| 101 | + # Use reasonable timeout to avoid stuck workflows |
| 102 | + timeout-minutes: 10 |
| 103 | + # Use Pages environment |
| 104 | + environment: |
| 105 | + name: github-pages |
| 106 | + url: ${{ steps.deployment.outputs.page_url }} |
| 107 | + permissions: |
| 108 | + # Needed to to deploy to Pages |
| 109 | + pages: write |
| 110 | + # Also needed to deploy to Pages |
| 111 | + id-token: write |
| 112 | + steps: |
| 113 | + - name: Deploy to GitHub Pages |
| 114 | + id: deployment |
| 115 | + |
0 commit comments