From 8fc3ec6ebd9525212d35f2dc44bc90431adf5502 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 9 May 2026 23:21:47 +0700 Subject: [PATCH] ci(deploy): switch from Cloudflare Pages to GitHub Pages Migrate build and deployment pipeline from Cloudflare Pages to GitHub Pages. Adds production-ready deploy workflow in deploy-github-pages.yml with proper artifact handling. Removes Cloudflare-specific tooling: wrangler config, _headers, _redirects, and CSP hash injection scripts (no longer needed with GitHub Pages static hosting). Updates package.json build scripts and all project documentation to reflect new deployment target and simplified architecture. --- web/.github/workflows/deploy-github-pages.yml | 43 ++------ web/.github/workflows/verify-build.yml | 1 - web/README.md | 9 +- web/docs/code-standards.md | 6 +- web/docs/codebase-summary.md | 12 +-- web/docs/deployment-guide.md | 98 ++++++------------ web/docs/development-roadmap.md | 2 +- web/docs/project-overview-pdr.md | 10 +- web/docs/system-architecture.md | 17 +--- web/package.json | 7 +- .../phase-01-wire-gh-pages-build-into-ci.md | 88 +++++++++++++++++ .../phase-02-remove-cloudflare-artifacts.md | 87 ++++++++++++++++ .../phase-03-update-docs-and-todo.md | 99 +++++++++++++++++++ .../plan.md | 41 ++++++++ web/plans/todo.md | 24 +---- web/scripts/inject-csp-hashes.mjs | 49 --------- web/scripts/verify-build-inline-scripts.mjs | 66 ------------- web/static/_headers | 14 --- web/static/_redirects | 10 -- web/wrangler.toml | 3 - 20 files changed, 385 insertions(+), 301 deletions(-) create mode 100644 web/plans/260509-2247-switch-deploy-to-github-pages/phase-01-wire-gh-pages-build-into-ci.md create mode 100644 web/plans/260509-2247-switch-deploy-to-github-pages/phase-02-remove-cloudflare-artifacts.md create mode 100644 web/plans/260509-2247-switch-deploy-to-github-pages/phase-03-update-docs-and-todo.md create mode 100644 web/plans/260509-2247-switch-deploy-to-github-pages/plan.md delete mode 100644 web/scripts/inject-csp-hashes.mjs delete mode 100644 web/scripts/verify-build-inline-scripts.mjs delete mode 100644 web/static/_headers delete mode 100644 web/static/_redirects delete mode 100644 web/wrangler.toml diff --git a/web/.github/workflows/deploy-github-pages.yml b/web/.github/workflows/deploy-github-pages.yml index a44afdf..4761065 100644 --- a/web/.github/workflows/deploy-github-pages.yml +++ b/web/.github/workflows/deploy-github-pages.yml @@ -1,4 +1,4 @@ -name: Deploy redirect to GitHub Pages +name: Deploy to GitHub Pages on: push: @@ -19,43 +19,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Generate redirect pages - run: | - set -euo pipefail - DEST="https://loto.miti99.com" - mkdir -p out/master - cat > out/index.html < - - - - - Lô tô — đã chuyển sang ${DEST} - - - - - - - -

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/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - run: npm run build:gh - uses: actions/configure-pages@v5 - uses: actions/upload-pages-artifact@v3 with: - path: out + path: build deploy: needs: build diff --git a/web/.github/workflows/verify-build.yml b/web/.github/workflows/verify-build.yml index 03b4a52..5980210 100644 --- a/web/.github/workflows/verify-build.yml +++ b/web/.github/workflows/verify-build.yml @@ -25,4 +25,3 @@ jobs: - run: npm ci - run: npm test - run: npm run build - - run: npm run verify:build diff --git a/web/README.md b/web/README.md index ec53be1..a6bffeb 100644 --- a/web/README.md +++ b/web/README.md @@ -31,12 +31,13 @@ path prefix and breaks the SvelteKit base path. ## Build ```bash -npm run build # default — root basePath, for Cloudflare Pages -npm run build:gh # /loto basePath, for tiennm99.github.io/loto manual export +npm run build # root basePath (local preview / generic static host) +npm run build:gh # /loto basePath, for tiennm99.github.io/loto ``` -Static export to `build/`. Deployed to Cloudflare Pages from `main` -(set up via the CF dashboard — see `docs/deployment-guide.md`). +Static export to `build/`. Deployed to GitHub Pages from `main` via +`.github/workflows/deploy-github-pages.yml` — see +`docs/deployment-guide.md`. ## Regenerating audio diff --git a/web/docs/code-standards.md b/web/docs/code-standards.md index eecbfbe..f282256 100644 --- a/web/docs/code-standards.md +++ b/web/docs/code-standards.md @@ -189,7 +189,7 @@ Set in `.env.local` (not committed). ### Build Targets - **adapter-static**: Generates static HTML + JS in `build/`. -- **basePath**: Dual-mode: `""` (Cloudflare, dev) or `/loto` (GitHub Pages via `BUILD_PROFILE=gh`). +- **basePath**: `/loto` for production GitHub Pages (`BUILD_PROFILE=gh`); `""` for local dev / generic static preview. -Last reviewed: 2026-04-27 -Last synced: 2026-04-27 (6-phase refactor) +Last reviewed: 2026-05-09 +Last synced: 2026-05-09 (deploy target switched to GitHub Pages) diff --git a/web/docs/codebase-summary.md b/web/docs/codebase-summary.md index 5136c2f..7be4e83 100644 --- a/web/docs/codebase-summary.md +++ b/web/docs/codebase-summary.md @@ -49,15 +49,13 @@ |------|---------| | `svelte.config.js` | adapter-static (HTML export), dual basePath via BUILD_PROFILE env, SvelteKit PWA plugin config. | | `vite.config.js` | Tailwind + SvelteKit + PWA plugins. codeserver HMR config (port, allowedHosts, hmr). | -| `package.json` | SvelteKit 2, Svelte 5 (runes), Tailwind 4, Vite, @vite-pwa/sveltekit. Scripts: dev, dev:codeserver, build, build:gh, lint, test, test:watch, verify:build. | -| `scripts/verify-build-inline-scripts.mjs` | Post-build CSP guard. Counts inline `