|
| 1 | +name: CI / Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: github-pages-${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +env: |
| 17 | + CI: true |
| 18 | + NODE_VERSION: '20' |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + |
| 24 | +jobs: |
| 25 | + build: |
| 26 | + name: Validate and build site |
| 27 | + runs-on: ubuntu-latest |
| 28 | + timeout-minutes: 15 |
| 29 | + permissions: |
| 30 | + contents: read |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 34 | + |
| 35 | + - name: Set up Node.js |
| 36 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 |
| 37 | + with: |
| 38 | + node-version: ${{ env.NODE_VERSION }} |
| 39 | + cache: 'npm' |
| 40 | + cache-dependency-path: package-lock.json |
| 41 | + |
| 42 | + - name: Install dependencies |
| 43 | + run: npm ci |
| 44 | + |
| 45 | + - name: Lint source |
| 46 | + run: npm run lint |
| 47 | + |
| 48 | + - name: Run test suite |
| 49 | + run: npm run test |
| 50 | + |
| 51 | + - name: Configure GitHub Pages |
| 52 | + run: npm run build |
| 53 | + |
| 54 | + pages-artifact: |
| 55 | + name: Prepare Pages artifact |
| 56 | + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' |
| 57 | + runs-on: ubuntu-latest |
| 58 | + needs: build |
| 59 | + timeout-minutes: 15 |
| 60 | + permissions: |
| 61 | + contents: read |
| 62 | + pages: write |
| 63 | + id-token: write |
| 64 | + steps: |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 67 | + |
| 68 | + - name: Set up Node.js |
| 69 | + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 |
| 70 | + with: |
| 71 | + node-version: ${{ env.NODE_VERSION }} |
| 72 | + cache: 'npm' |
| 73 | + cache-dependency-path: package-lock.json |
| 74 | + |
| 75 | + - name: Install dependencies |
| 76 | + run: npm ci |
| 77 | + |
| 78 | + - name: Configure GitHub Pages |
| 79 | + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 |
| 80 | + |
| 81 | + - name: Build production bundle |
| 82 | + run: npm run build |
| 83 | + |
| 84 | + - name: Upload Pages artifact |
| 85 | + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 |
| 86 | + with: |
| 87 | + path: dist |
| 88 | + |
| 89 | + deploy: |
| 90 | + name: Deploy site |
| 91 | + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' |
| 92 | + environment: |
| 93 | + name: github-pages |
| 94 | + url: ${{ steps.deployment.outputs.page_url }} |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: pages-artifact |
| 97 | + timeout-minutes: 10 |
| 98 | + permissions: |
| 99 | + pages: write |
| 100 | + id-token: write |
| 101 | + steps: |
| 102 | + - name: Deploy to GitHub Pages |
| 103 | + id: deployment |
| 104 | + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |
0 commit comments