mirror of
https://github.com/tiennm99/loto.git
synced 2026-09-03 12:21:53 +00:00
refactor: cf-only deploy via dashboard, drop gh actions
- Default `npm run build` now produces a root-relative build (CF Pages custom domain at loto.miti99.com). The /loto basePath is opt-in via `npm run build:gh` for the rare manual GH Pages export. - Removed both GitHub Actions deploy workflows (.github/workflows/) and the dangling `build:cf` script (it was identical to `build` after the default flip). - next.config.mjs: simplified basePath logic — only `BUILD_PROFILE=gh` toggles a non-empty path; everything else (CF, local dev) is root.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
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:cf
|
||||
- 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 }}
|
||||
@@ -1,40 +0,0 @@
|
||||
name: Deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
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:gh
|
||||
- uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: out
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
steps:
|
||||
- id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
@@ -30,4 +30,4 @@ Use `/absproxy/{port}/`, **not** `/proxy/{port}/` — the latter strips the path
|
||||
npm run build
|
||||
```
|
||||
|
||||
Static export to `out/`. Deployed to GitHub Pages from `master` via `.github/workflows/deploy.yml`.
|
||||
Static export to `out/`. Deployed to Cloudflare Pages from `master` (set up via the CF dashboard — see `docs/deployment-guide.md`).
|
||||
|
||||
+18
-39
@@ -2,38 +2,25 @@
|
||||
|
||||
## Build Profiles
|
||||
|
||||
Two named profiles select the basePath for the deploy target:
|
||||
|
||||
| Script | basePath | Target URL |
|
||||
| Script | basePath | Target |
|
||||
|---|---|---|
|
||||
| `npm run build:gh` | `/loto` | `https://tiennm99.github.io/loto` |
|
||||
| `npm run build:cf` | `""` (root) | `https://loto.miti99.com` |
|
||||
| `npm run build` | `/loto` | legacy default — same as `build:gh` |
|
||||
| `npm run build` | `""` (root) | Cloudflare Pages → `https://loto.miti99.com` |
|
||||
| `npm run build:gh` | `/loto` | GitHub Pages → `https://tiennm99.github.io/loto` (manual fallback) |
|
||||
|
||||
Implementation: `next.config.mjs` reads `BUILD_PROFILE` (`gh` or `cf`) and
|
||||
picks the basePath. `NEXT_BASE_PATH` overrides everything for one-off
|
||||
custom-domain builds.
|
||||
Implementation: `next.config.mjs` reads `BUILD_PROFILE`. Default is empty
|
||||
basePath; `BUILD_PROFILE=gh` switches to `/loto`. `NEXT_BASE_PATH`
|
||||
overrides everything for one-off custom-domain builds.
|
||||
|
||||
## Production Deployment
|
||||
## Production Deployment — Cloudflare Pages
|
||||
|
||||
### GitHub Pages
|
||||
Primary deploy. Set up via the Cloudflare dashboard once; subsequent
|
||||
pushes to `master` trigger automatic builds + deploys.
|
||||
|
||||
Auto-deploys from `master` via `.github/workflows/deploy.yml`. Runs
|
||||
`npm run build:gh`, then uploads `out/` as a Pages artifact.
|
||||
|
||||
URL: `https://tiennm99.github.io/loto`. basePath `/loto` because GH Pages
|
||||
serves the project under that path prefix.
|
||||
|
||||
### Cloudflare Pages
|
||||
|
||||
Custom domain target: `https://loto.miti99.com` (basePath `""`).
|
||||
|
||||
**Option A — Dashboard:**
|
||||
1. dash.cloudflare.com → Workers & Pages → Create → Pages → Connect to Git
|
||||
→ pick the repo
|
||||
2. Build settings:
|
||||
- Framework preset: `Next.js (Static HTML Export)`
|
||||
- Build command: `npm run build:cf`
|
||||
- Build command: `npm run build`
|
||||
- Build output directory: `out`
|
||||
- Production branch: `master`
|
||||
3. After first deploy, add the custom domain:
|
||||
@@ -41,28 +28,20 @@ Custom domain target: `https://loto.miti99.com` (basePath `""`).
|
||||
records to add at your registrar (or auto-configures if `miti99.com` is
|
||||
on Cloudflare DNS).
|
||||
|
||||
**Option B — GitHub Actions (`.github/workflows/deploy-cloudflare-pages.yml`):**
|
||||
No GitHub Actions involved; no repo secrets needed.
|
||||
|
||||
Add two repo secrets:
|
||||
- `CLOUDFLARE_API_TOKEN` — dash → My Profile → API Tokens → Create with the
|
||||
`Pages — Edit` template
|
||||
- `CLOUDFLARE_ACCOUNT_ID` — visible in the dash sidebar
|
||||
## Manual GH Pages Deploy (optional)
|
||||
|
||||
The workflow runs `npm run build:cf`, then publishes `out/` via
|
||||
`cloudflare/wrangler-action@v3` to a Pages project named `loto`. Custom
|
||||
domain setup is the same dashboard step as Option A — done once.
|
||||
|
||||
The two providers can run in parallel — different artifacts, different
|
||||
URLs. Drop whichever you stop wanting by deleting its workflow file.
|
||||
|
||||
### Manual Deploy
|
||||
If you ever want to push a build to GitHub Pages by hand:
|
||||
|
||||
```bash
|
||||
npm run build:gh # for GH Pages
|
||||
npm run build:cf # for CF Pages / any root-served host
|
||||
# out/ directory ready for upload to any static host
|
||||
npm run build:gh
|
||||
# upload out/ to the GH Pages target
|
||||
```
|
||||
|
||||
The repo no longer auto-deploys to GH Pages — there's no GitHub Actions
|
||||
workflow. CF Pages is the only auto-deploy target.
|
||||
|
||||
## Development Environment
|
||||
|
||||
### Local Dev
|
||||
|
||||
+5
-13
@@ -1,9 +1,8 @@
|
||||
const isProd = process.env.NODE_ENV === "production";
|
||||
const isCodeserver = process.env.NEXT_DEV_PROFILE === "codeserver";
|
||||
|
||||
// Build profiles select basePath for the deploy target:
|
||||
// gh — GitHub Pages, served at tiennm99.github.io/loto
|
||||
// cf — Cloudflare Pages, served at loto.miti99.com (custom domain, root)
|
||||
// (default) — Cloudflare Pages, served at loto.miti99.com (root)
|
||||
// gh — GitHub Pages, served at tiennm99.github.io/loto
|
||||
const buildProfile = process.env.BUILD_PROFILE;
|
||||
|
||||
// In dev under code-server's reverse proxy, basePath/assetPrefix must match
|
||||
@@ -27,19 +26,12 @@ const cs = isCodeserver ? codeserverConfig() : null;
|
||||
// basePath resolution order (first non-null wins):
|
||||
// 1. NEXT_BASE_PATH — explicit override (escape hatch for forks / custom domains)
|
||||
// 2. codeserver dev profile
|
||||
// 3. BUILD_PROFILE=gh|cf — explicit deploy target
|
||||
// 4. NODE_ENV=production — legacy fallback (bare `npm run build` → GH Pages)
|
||||
// 5. local dev — empty
|
||||
// 3. BUILD_PROFILE=gh — explicit GH Pages target
|
||||
// 4. default — empty (CF Pages / local dev / any root-served host)
|
||||
const basePath =
|
||||
process.env.NEXT_BASE_PATH ??
|
||||
cs?.basePath ??
|
||||
(buildProfile === "gh"
|
||||
? "/loto"
|
||||
: buildProfile === "cf"
|
||||
? ""
|
||||
: isProd
|
||||
? "/loto"
|
||||
: "");
|
||||
(buildProfile === "gh" ? "/loto" : "");
|
||||
|
||||
const nextConfig = {
|
||||
output: "export",
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"dev:codeserver": "NEXT_DEV_PROFILE=codeserver next dev -H 0.0.0.0",
|
||||
"build": "next build",
|
||||
"build:gh": "BUILD_PROFILE=gh next build",
|
||||
"build:cf": "BUILD_PROFILE=cf next build",
|
||||
"start": "next start",
|
||||
"lint": "eslint"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user