mirror of
https://github.com/tiennm99/loto.git
synced 2026-10-03 07:13:18 +00:00
feat: add Cloudflare Pages deployment support
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.
This commit is contained in:
1 parent
e2dab7dd4e
commit
0916f7706f
3 files changed
+80
-14
No files matched your search
@@ -0,0 +1,36 @@
|
||||
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 }}
|
||||
Reference in new issue
Block a user