mirror of
https://github.com/tiennm99/loto.git
synced 2026-10-03 07:13:18 +00:00
next.config.mjs now detects CF_PAGES=1 (auto-injected by Cloudflare during build) and switches basePath from /loto to "" — assets resolve at the project root on loto.pages.dev. GH Pages keeps /loto unchanged. New workflow .github/workflows/deploy-cloudflare-pages.yml mirrors the GH Pages flow but publishes via cloudflare/wrangler-action@v3. Requires repo secrets CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID; project name "loto" is hardcoded — adjust --project-name= in the workflow if your CF Pages project uses a different name. Dashboard-based deploys also work without code changes thanks to the CF_PAGES detection. See docs/deployment-guide.md for both paths.
37 lines
930 B
YAML
37 lines
930 B
YAML
name: Deploy to Cloudflare Pages
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
deployments: write
|
|
|
|
concurrency:
|
|
group: cf-pages
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
- run: npm ci
|
|
- run: npm run build
|
|
env:
|
|
# Force root basePath: CF Pages serves the site at the project root
|
|
# (loto.pages.dev), unlike GH Pages which prefixes with /loto.
|
|
NEXT_BASE_PATH: ""
|
|
- name: Publish to Cloudflare Pages
|
|
uses: cloudflare/wrangler-action@v3
|
|
with:
|
|
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
|
command: pages deploy out --project-name=loto --branch=${{ github.ref_name }}
|