diff --git a/web/.github/workflows/deploy-github-pages.yml b/web/.github/workflows/deploy-github-pages.yml index 4761065..a44afdf 100644 --- a/web/.github/workflows/deploy-github-pages.yml +++ b/web/.github/workflows/deploy-github-pages.yml @@ -1,4 +1,4 @@ -name: Deploy to GitHub Pages +name: Deploy redirect to GitHub Pages on: push: @@ -19,16 +19,43 @@ jobs: 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 + - name: Generate redirect pages + run: | + set -euo pipefail + DEST="https://loto.miti99.com" + mkdir -p out/master + cat > out/index.html < + +
+ + +Trang đã chuyển sang ${DEST}
+ + + HTML + # Mirror to /master so deep links also redirect cleanly + cp out/index.html out/master/index.html - uses: actions/configure-pages@v5 - uses: actions/upload-pages-artifact@v3 with: - path: build + path: out deploy: needs: build diff --git a/web/docs/deployment-guide.md b/web/docs/deployment-guide.md index cfa8071..631e016 100644 --- a/web/docs/deployment-guide.md +++ b/web/docs/deployment-guide.md @@ -32,26 +32,40 @@ pushes to `main` trigger automatic builds + deploys. No GitHub Actions involved; no repo secrets needed. -## GitHub Pages (parallel auto-deploy) +## GitHub Pages (redirect-only) -`.github/workflows/deploy-github-pages.yml` runs on every push to `main`, -builds with `npm run build:gh` (basePath `/loto`), and publishes `build/` -as a Pages artifact. +`.github/workflows/deploy-github-pages.yml` no longer builds the app. +It generates two tiny HTML pages (`/loto/index.html` and +`/loto/master/index.html`) that immediately redirect to the canonical +URL on Cloudflare Pages. -URL: `https://tiennm99.github.io/loto`. +The redirect uses both `` (no-JS fallback) +and a tiny inline script that preserves path / query / hash: -CF Pages and GH Pages run in parallel — different URLs, different -artifacts, no conflict. Drop GH Pages by deleting the workflow file. +```js +location.replace("https://loto.miti99.com" + path + search + hash); +``` -### Manual GH Pages Deploy +So `tiennm99.github.io/loto/` → `loto.miti99.com/` and +`tiennm99.github.io/loto/master` → `loto.miti99.com/master`. -If you'd rather export by hand: +The redirect runs on every push to `main`. If you want full GH Pages +serving back (instead of the redirect), restore the prior version of +`.github/workflows/deploy-github-pages.yml` from git history — it ran +`npm run build:gh` and uploaded the `build/` artifact. + +### Manual GH Pages Build (still available) + +If you ever want to build a real GH Pages export by hand: ```bash npm run build:gh -# upload build/ to the GH Pages target +# upload build/ to the GH Pages target manually ``` +`build:gh` script kept as an escape hatch — not used by the automated +redirect workflow. + ## Development Environment ### Local Dev @@ -155,11 +169,12 @@ Generates: ## CI/CD Pipeline -Both providers auto-deploy on push to `main`: -- **Cloudflare Pages** — wired via the CF dashboard, builds with `npm run build`, - publishes to `loto.miti99.com`. -- **GitHub Pages** — wired via `.github/workflows/deploy-github-pages.yml`, - builds with `npm run build:gh`, publishes to `tiennm99.github.io/loto`. +Two pipelines run on push to `main`: +- **Cloudflare Pages** (canonical) — wired via the CF dashboard, builds with + `npm run build`, publishes to `loto.miti99.com`. +- **GitHub Pages** (redirect-only) — wired via + `.github/workflows/deploy-github-pages.yml`, deploys static redirect HTML + that forwards `tiennm99.github.io/loto/*` to `loto.miti99.com/*`. ## Performance Checklist diff --git a/web/docs/project-overview-pdr.md b/web/docs/project-overview-pdr.md index 3f4fc4a..302bf68 100644 --- a/web/docs/project-overview-pdr.md +++ b/web/docs/project-overview-pdr.md @@ -31,7 +31,7 @@ State is entirely client-side. Each page/card instance uses a unique localStorag ## Deployment -- **Production**: dual auto-deploy on push to `main` — Cloudflare Pages at `loto.miti99.com` (CF dashboard, root basePath) and GitHub Pages at `tiennm99.github.io/loto` (`.github/workflows/deploy-github-pages.yml`, `/loto` basePath via `npm run build:gh`). +- **Production**: Cloudflare Pages at `loto.miti99.com` (canonical, CF dashboard, root basePath). GitHub Pages serves only a redirect to the canonical URL via `.github/workflows/deploy-github-pages.yml`. - **Development**: `npm run dev` (local), `npm run dev:codeserver` (code-server via proxy). - **Build**: `npm run build` generates static export to `build/` directory.