diff --git a/web/.github/workflows/deploy-github-pages.yml b/web/.github/workflows/deploy-github-pages.yml new file mode 100644 index 0000000..4761065 --- /dev/null +++ b/web/.github/workflows/deploy-github-pages.yml @@ -0,0 +1,41 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: github-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/configure-pages@v5 + - uses: actions/upload-pages-artifact@v3 + with: + path: build + + 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 diff --git a/web/docs/deployment-guide.md b/web/docs/deployment-guide.md index 52a6f16..cfa8071 100644 --- a/web/docs/deployment-guide.md +++ b/web/docs/deployment-guide.md @@ -32,18 +32,26 @@ pushes to `main` trigger automatic builds + deploys. No GitHub Actions involved; no repo secrets needed. -## Manual GH Pages Deploy (optional) +## GitHub Pages (parallel auto-deploy) -If you ever want to push a build to GitHub Pages by hand: +`.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. + +URL: `https://tiennm99.github.io/loto`. + +CF Pages and GH Pages run in parallel — different URLs, different +artifacts, no conflict. Drop GH Pages by deleting the workflow file. + +### Manual GH Pages Deploy + +If you'd rather export by hand: ```bash npm run build:gh # upload build/ 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 @@ -147,10 +155,11 @@ Generates: ## CI/CD Pipeline -Cloudflare Pages handles CI/CD automatically: -- GitHub Pages deployment removed (Cloudflare is primary). -- Manual fallback: `npm run build:gh && git push` (if needed). -- No GitHub Actions workflow for automatic GH Pages deploy. +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`. ## Performance Checklist diff --git a/web/docs/project-overview-pdr.md b/web/docs/project-overview-pdr.md index 49875d9..3f4fc4a 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**: Cloudflare Pages auto-deploys from `main` branch (configured via the CF dashboard, no GitHub Actions). Custom domain `loto.miti99.com`. `npm run build:gh` is a manual fallback for GitHub Pages at the `/loto` basePath. +- **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`). - **Development**: `npm run dev` (local), `npm run dev:codeserver` (code-server via proxy). - **Build**: `npm run build` generates static export to `build/` directory.