From e0a2424f3bd545411132f479e7fa77cdc5fe1106 Mon Sep 17 00:00:00 2001 From: Ofer Shaal Date: Wed, 3 Jun 2026 12:29:05 -0400 Subject: [PATCH] Configure GitHub Pages deployment - Set Vite base path to /agentics.org/ for the project Pages subpath - Add router basename so React Router resolves routes under the subpath - Emit dist/404.html as SPA fallback (Pages has no rewrite for deep links) - Add GitHub Actions workflow to build and deploy on push to main --- .github/workflows/deploy.yml | 44 ++++++++++++++++++++++++++++++++++++ src/App.tsx | 2 +- vite.config.ts | 21 +++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..71dd6c7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,44 @@ +name: Deploy to GitHub Pages + +on: + # Deploy on every push to main. + push: + branches: [main] + # Allow manual runs from the Actions tab. + workflow_dispatch: + +# Permissions the GITHUB_TOKEN needs to publish to Pages. +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment; don't cancel an in-progress run. +concurrency: + group: pages + cancel-in-progress: false + +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 + - uses: actions/upload-pages-artifact@v3 + with: + path: dist + + 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/src/App.tsx b/src/App.tsx index 877632f..b31d25f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,7 +15,7 @@ import Membership from './pages/Membership'; export default function App() { return ( - + }> } /> diff --git a/vite.config.ts b/vite.config.ts index 0506f1b..113a25b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,12 +1,29 @@ import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; +import fs from 'fs'; import path from 'path'; import {defineConfig, loadEnv} from 'vite'; -export default defineConfig(({mode}) => { +// GitHub Pages has no SPA fallback: a hard refresh on /about would 404. +// Copying the built index.html to 404.html makes Pages serve the app on any +// unknown path, and React Router (via basename) then renders the right route. +const spaFallback = () => ({ + name: 'spa-404-fallback', + closeBundle() { + const index = path.resolve(__dirname, 'dist/index.html'); + if (fs.existsSync(index)) { + fs.copyFileSync(index, path.resolve(__dirname, 'dist/404.html')); + } + }, +}); + +export default defineConfig(({mode, command}) => { const env = loadEnv(mode, '.', ''); return { - plugins: [react(), tailwindcss()], + // Project site lives at https://shaal.github.io/agentics.org/ in prod. + // Keep '/' for local dev so the dev server behaves normally. + base: command === 'build' ? '/agentics.org/' : '/', + plugins: [react(), tailwindcss(), spaFallback()], define: { 'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY), },