feat(web): port homepage to Astro static page #61
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: | |
| - ".github/workflows/deploy-site.yml" | |
| - "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 | |
| # HTML pages and the three metadata files share a 5-minute edge TTL | |
| # with stale-while-revalidate for 1 hour. A Cloudflare Cache Rule on | |
| # the zone enables caching for these specific paths (extensionless | |
| # HTML isn't cached by Cloudflare default); see infrastructure notes | |
| # in apps/web/README.md. Static assets (favicons, og-image, logo) | |
| # keep Cloudflare's default static-asset cache behavior - no header. | |
| CACHE_HTML="public, max-age=300, stale-while-revalidate=3600" | |
| # Non-HTML assets: copy the finite Astro output directly. Do not use | |
| # `aws s3 sync` at the bucket root because the same bucket also stores | |
| # the million-plus scraper-managed /documents/ and /extracted/ objects. | |
| find apps/web/dist -type f ! -name "*.html" -print0 | while IFS= read -r -d '' f; do | |
| rel="${f#apps/web/dist/}" | |
| case "$rel" in | |
| sitemap.xml|robots.txt|llms.txt) | |
| aws s3 cp "$f" "$R2_BUCKET/$rel" \ | |
| --cache-control "$CACHE_HTML" \ | |
| --endpoint-url "$R2_ENDPOINT" | |
| ;; | |
| *) | |
| aws s3 cp "$f" "$R2_BUCKET/$rel" \ | |
| --endpoint-url "$R2_ENDPOINT" | |
| ;; | |
| esac | |
| done | |
| # 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" \ | |
| --cache-control "$CACHE_HTML" \ | |
| --endpoint-url "$R2_ENDPOINT" | |
| done |