Add Gitea Actions workflow for git-pages deployment
Deploy to git-pages / deploy (push) Successful in 10s
Deploy to git-pages / deploy (push) Successful in 10s
Adapts the sln-school-comparison pattern: builds Vite static site in CI, then copies dist/ to a pages branch served by the git-pages webhook at pages.civilytics.org/crdc-demo/
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
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.
|
||||
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
|
||||
+3
-25
@@ -1,29 +1,7 @@
|
||||
# Git Pages (Jekyll) configuration — for self-hosted static site deployment.
|
||||
# Matches the civilytics.org hosting setup where you have a GitHub/GitLab Pages equivalent.
|
||||
# Git Pages configuration — for self-hosted static site deployment.
|
||||
# This file is informational; the actual build + deploy happens via .gitea/workflows/pages.yml.
|
||||
# The workflow builds the Vite app, then copies dist/ to a `pages` branch served by git-pages.
|
||||
|
||||
title: CRDC Arrests API Demo
|
||||
description: "Explore school-based arrest rates by U.S. district with Bayesian model comparisons."
|
||||
author: Civilytics Consulting LLC
|
||||
|
||||
# Exclude non-essential files from Jekyll processing
|
||||
exclude:
|
||||
- node_modules
|
||||
- .git
|
||||
- .github
|
||||
- Dockerfile
|
||||
- docker-compose.yml
|
||||
- src
|
||||
- package.json
|
||||
- package-lock.json
|
||||
- vite.config.js
|
||||
- eslint.config.*
|
||||
|
||||
# Keep the static build output as-is (no Jekyll processing of JS/CSS)
|
||||
keep_files:
|
||||
- dist/
|
||||
|
||||
# Markdown settings for any docs pages
|
||||
markdown: kramdown
|
||||
kramdown:
|
||||
syntax_highlighter_opts:
|
||||
blockquote_plain_markdown: true
|
||||
|
||||
Reference in New Issue
Block a user