ci: install Node 22 for Astro #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Site | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "apps/web/**" | |
| - "!apps/web/worker/**" | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build site | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| run: bun run --cwd apps/web build | |
| - name: Upload site to R2 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: auto | |
| AWS_REGION: auto | |
| R2_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com | |
| R2_BUCKET: s3://${{ secrets.R2_BUCKET_NAME }} | |
| run: | | |
| set -euo pipefail | |
| # Non-HTML assets: sync with their natural extensions and content types. | |
| # No --delete: the bucket also holds /documents/ and /extracted/ which | |
| # are scraper-managed and must not be touched by this workflow. | |
| aws s3 sync apps/web/dist/ "$R2_BUCKET/" \ | |
| --exclude "*.html" \ | |
| --endpoint-url "$R2_ENDPOINT" | |
| # HTML files: upload to extensionless keys to match canonical URLs. | |
| # /classification.html -> r2://classification, /types/legal.html -> r2://types/legal. | |
| # index.html is the one exception; it stays as a static homepage at /. | |
| find apps/web/dist -name "*.html" -print0 | while IFS= read -r -d '' f; do | |
| rel="${f#apps/web/dist/}" | |
| if [ "$rel" = "index.html" ]; then | |
| key="index.html" | |
| else | |
| key="${rel%.html}" | |
| fi | |
| aws s3 cp "$f" "$R2_BUCKET/$key" \ | |
| --content-type "text/html; charset=utf-8" \ | |
| --endpoint-url "$R2_ENDPOINT" | |
| done |