Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Membership from './pages/Membership';

export default function App() {
return (
<Router>
<Router basename={import.meta.env.BASE_URL}>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
Expand Down
21 changes: 19 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -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),
},
Expand Down