diff --git a/.github/workflows/pages.yml b/.github/workflows/site.yml similarity index 51% rename from .github/workflows/pages.yml rename to .github/workflows/site.yml index da66fca..b475ace 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/site.yml @@ -1,4 +1,4 @@ -name: Build and deploy the Captua site with Hugo +name: Build the Captua site with Hugo and deploy it to Cloudflare on: push: @@ -10,7 +10,7 @@ permissions: contents: read concurrency: - group: pages-${{ github.ref }} + group: site-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: @@ -28,21 +28,11 @@ jobs: - run: npm ci - run: npm run build - run: npm test - - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + - name: Deploy to Cloudflare + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3 with: - path: public - - deploy: - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' - needs: build - runs-on: ubuntu-latest - permissions: - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + wranglerVersion: '4.152.0' + command: deploy diff --git a/README.md b/README.md index 596dd5c..8884305 100644 --- a/README.md +++ b/README.md @@ -52,4 +52,4 @@ npm test The production build writes `public/` and builds the search index. `npm test` checks the built site: internal links and fragments resolve, every image exists and has alt text, every page has one title and one H1 and is not empty, canonical addresses and the robots policy match the build, no URL carries a token or other credential, both language search indexes are present, the sitemap index covers both languages, and every English page with a `translationKey` has a Spanish page or is listed in `data/translations_pending.json`. Results are written to the ignored `reports/` directory. -The Pages workflow in `.github/workflows/pages.yml` builds and tests every pull request. It runs the deployment job only for `main`, after the checks pass, and that job publishes `public/`. `static/CNAME` sets the custom domain. +The workflow in `.github/workflows/site.yml` builds and tests every pull request. On a push to `main`, after the checks pass, it deploys `public/` to Cloudflare Workers as static assets with Wrangler, using `wrangler.jsonc`, which also sets the custom domain `captua.org`. The deploy reads two repository secrets, `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID`. diff --git a/scripts/verify.py b/scripts/verify.py index 5dc8a44..512166c 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -271,7 +271,13 @@ def route_of(file): for entry in json.loads((ROOT / 'migration/sources.json').read_text())['pages']: check(entry['url'] in routes, f"Expected page not built: {entry['url']}") check(entry.get('translationKey') not in drafts, f"Expected page is a draft: {entry['url']}") -check((PUBLIC / 'CNAME').exists() and (PUBLIC / 'CNAME').read_text().strip() == 'captua.org', 'CNAME missing or wrong') +# Deployment: wrangler.jsonc serves public/ and binds the custom domain captua.org. +try: + wr = json.loads('\n'.join(l for l in (ROOT / 'wrangler.jsonc').read_text().splitlines() if not l.lstrip().startswith('//'))) + check(wr.get('assets', {}).get('directory') == './public', 'wrangler.jsonc does not serve ./public') + check({'pattern': 'captua.org', 'custom_domain': True} in wr.get('routes', []), 'wrangler.jsonc lacks the captua.org custom domain') +except (OSError, ValueError) as e: + check(False, f'wrangler.jsonc unreadable: {e}') check(('Disallow: /' in (PUBLIC / 'robots.txt').read_text()) == preview, 'Wrong robots policy') out = {'checks': checks, 'failures': len(errors), 'preview': preview, 'pages': len(pages), diff --git a/static/CNAME b/static/CNAME deleted file mode 100644 index a19fc43..0000000 --- a/static/CNAME +++ /dev/null @@ -1 +0,0 @@ -captua.org diff --git a/wrangler.jsonc b/wrangler.jsonc new file mode 100644 index 0000000..b5a5ca4 --- /dev/null +++ b/wrangler.jsonc @@ -0,0 +1,13 @@ +// Serves the built site (public/) as static assets on Cloudflare Workers. +// The GitHub Actions workflow deploys it from main; see README.md. +{ + "name": "captua-docs", + "compatibility_date": "2026-11-08", + "assets": { + "directory": "./public", + "not_found_handling": "404-page" + }, + "routes": [ + { "pattern": "captua.org", "custom_domain": true } + ] +}