Deploy to git-pages / deploy (push) Successful in 20s
- Add VITE_PROXY_URL env var to route requests through a CORS proxy when deployed as static site (CRDC API doesn't send Access-Control-Allow-Origin) - Update useApi.js, LoadingAnimation.jsx, and ChartPanel.jsx to respect proxy - Add nginx.conf with /api/v1/ reverse proxy + CORS headers for Docker deployment - Include proxy.php — simple PHP CORS proxy for git-pages hosts that support PHP - Document CORS workaround in README Without this fix, browser fetch() calls are blocked by same-origin policy and the app shows a blank white screen despite serving correct HTML.
63 lines
1.9 KiB
YAML
63 lines
1.9 KiB
YAML
name: Deploy to git-pages
|
|
|
|
# Builds the Vite static site and pushes it to the `pages` branch, which
|
|
# the git-pages webhook receiver at pages.civilytics.org serves.
|
|
# URL: https://pages.civilytics.org/crdc-demo/
|
|
# Same pattern as Civilytics/sln-school-comparison.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'src/**'
|
|
- 'index.html'
|
|
- 'vite.config.mjs'
|
|
- 'package.json'
|
|
- '.gitea/workflows/pages.yml'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies & build static site
|
|
run: |
|
|
npm ci
|
|
# VITE_API_BASE defaults to the production API; override if needed via secrets.
|
|
# For git-pages deployment, CORS is handled by setting up a proxy endpoint on the server.
|
|
npm run build
|
|
|
|
- name: Publish dist/ to pages branch
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.civilytics.org"
|
|
|
|
# Use the GITHUB_TOKEN for authentication (works with Gitea token auth)
|
|
TOKEN="${{ secrets.GITHUB_TOKEN }}"
|
|
if [ -z "$TOKEN" ]; then
|
|
echo "GITHUB_TOKEN not available; skipping deploy."
|
|
exit 0
|
|
fi
|
|
|
|
git remote set-url origin "https://token:${TOKEN}@gitea.civilytics.org/Civilytics/crdc-demo.git"
|
|
|
|
# Create orphan pages branch with only the built files
|
|
rm -rf /tmp/pages-branch
|
|
git worktree add --orphan -B pages /tmp/pages-branch
|
|
|
|
cp -r dist/. /tmp/pages-branch/
|
|
echo "${GITHUB_SHA}" > /tmp/pages-branch/deploy-sha.txt
|
|
|
|
cd /tmp/pages-branch
|
|
git add --all
|
|
git commit -m "Deploy from ${GITHUB_SHA}" || echo "No changes to deploy"
|
|
git push origin pages --force
|