Skip to content
Merged
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
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,49 @@ jobs:
docker compose --project-name githubble --env-file .env -f docker-compose.yaml ps
REMOTE

pages-build:
name: Build GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [go, go-lint, frontend, docker]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: '22'
cache: npm
cache-dependency-path: frontend/package-lock.json
- uses: actions/configure-pages@v5
- name: Build static export
working-directory: frontend
env:
GITHUB_PAGES: 'true'
PAGES_BASE_PATH: /${{ github.event.repository.name }}
NEXT_PUBLIC_SSE_URL: ${{ vars.PAGES_SSE_URL || 'https://githubble.root.sx/api/events' }}
NEXT_TELEMETRY_DISABLED: '1'
run: |
npm ci
# Route handlers cannot be exported statically; the stream comes from the public deployment.
rm -rf src/app/api
npm run build
- uses: actions/upload-pages-artifact@v4
with:
path: frontend/out

pages-deploy:
name: Deploy to GitHub Pages
needs: pages-build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4

notify:
name: Notify Telegram
if: always() && !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dist
# Dependency directory
node_modules
.next
out
*.tsbuildinfo

# Optional npm cache directory
Expand Down
8 changes: 7 additions & 1 deletion frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// GitHub Pages build: a static export with no API route (the workflow removes
// src/app/api) that streams from the public deployment via NEXT_PUBLIC_SSE_URL.
const pages = process.env.GITHUB_PAGES === "true";

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
output: "standalone",
output: pages ? "export" : "standalone",
basePath: pages ? process.env.PAGES_BASE_PATH || "" : "",
images: pages ? { unoptimized: true } : undefined,
};

export default nextConfig;
2 changes: 2 additions & 0 deletions frontend/src/app/api/events/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export async function GET(request: Request) {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache, no-transform",
"X-Accel-Buffering": "no",
// The stream is public; allow the GitHub Pages build to read it.
"Access-Control-Allow-Origin": "*",
},
});
} catch {
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Stream via the same-origin Next.js route: the browser never needs to know
// the backend's internal Docker hostname or a public backend port.
// the backend's internal Docker hostname or a public backend port. The static
// GitHub Pages build overrides it with the public deployment's stream URL.
export const CONFIG = {
numEventsOnPageValues: [15, 30, 50, 70, 90, 110],
sseUrl: "/api/events",
sseUrl: process.env.NEXT_PUBLIC_SSE_URL || "/api/events",
};
Loading