mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
GitHub becomes the primary repository host; the site keeps its VPS + nginx + Dockge host, the three-job pipeline and the same concurrency, so what moves is the CI host and the write-path target. .github/workflows/{deploy,deploy-infra}.yml are ports of the Gitea files with permissions: contents: read on every job. .gitea/workflows/ stays until the first green GitHub run (D9); its infra test step carries the new template variable names because the template it validates is the one this repository now ships.
The write-path values are renamed GITEA_TOKEN / GITEA_CONTENTS_API -> CONTENT_API_TOKEN / CONTENT_API_BASE and the upstream header becomes Bearer — in nginx.conf, in the compose envsubst filter and in the dev proxy, so dev and production send the identical header (D4). draft.ts learns GitHub's answer to a stale blob sha (409) while keeping the 422 "does not match" and 412 legs; smoke-draft.ts check 14 drives a stubbed proxy that answers 409 with GitHub's body and asserts the conflict refreshes the base, keeps the draft and never stops the save sequence.
Both workflows read the stack directory and the compose service / container name from the STACK_DIR and CONTAINER_NAME repository variables instead of hard-coding them, and each job refuses a missing, relative, trailing-slash or compose-disagreeing value in its first step, before any artifact download or rsync reaches the VPS (D15).
Verified: tsc -b and oxlint pass with no new warnings; validate:content, smoke-draft (14 checks) and smoke-generated-ids (7 checks) pass; both workflows parse, every run/script block passes bash -n with the variables substituted, and the guard refuses every bad value against the real compose.yaml. Owner-side variables, secrets, the write token and the VPS config rewrite stay open in spec-v6 §6.
142 lines
4.2 KiB
YAML
142 lines
4.2 KiB
YAML
name: Deploy Static Site
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- feature/github-migration
|
|
|
|
|
|
concurrency:
|
|
group: deploy
|
|
cancel-in-progress: false
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
# Site identity (spec-v4-deploy-infra D10/D12, spec-v6 D3): the build and the
|
|
# resume generator derive every published URL and the page title from these two
|
|
# values; the build fails loudly when either is missing. They are repository
|
|
# variables — public values, not secrets.
|
|
env:
|
|
SITE_URL: ${{ vars.SITE_URL }}
|
|
SITE_NAME: ${{ vars.SITE_NAME }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: pnpm/setup@v3
|
|
with:
|
|
cache: true
|
|
version: ^12.0.0
|
|
runtime: node@24
|
|
- run: pnpm tsx scripts/validate-content.ts
|
|
- run: pnpm build
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: static-site
|
|
path: dist/
|
|
retention-days: 5
|
|
|
|
generate-resume:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
contents: read
|
|
env:
|
|
SITE_URL: ${{ vars.SITE_URL }}
|
|
SITE_NAME: ${{ vars.SITE_NAME }}
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: pnpm/setup@v3
|
|
with:
|
|
cache: true
|
|
version: ^12.0.0
|
|
runtime: node@24
|
|
|
|
# Cache Playwright browser — download once, reuse
|
|
- name: Cache Playwright browser
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/ms-playwright
|
|
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
playwright-${{ runner.os }}-
|
|
|
|
- run: pnpm install --frozen-lockfile
|
|
- run: npx playwright install chromium
|
|
- run: npx playwright install-deps chromium
|
|
|
|
# Generate English version (default)
|
|
- run: pnpm tsx scripts/generate-resume.ts --lang=en
|
|
|
|
# Generate Vietnamese version
|
|
- run: pnpm tsx scripts/generate-resume.ts --lang=vi
|
|
|
|
# Upload both PDF artifacts
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: resume-pdf-en
|
|
path: dist/resume.pdf
|
|
retention-days: 1
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: resume-pdf-vi
|
|
path: dist/resume-vi.pdf
|
|
retention-days: 1
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: [build, generate-resume]
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
# The stack directory is the server's deployment layout, not repository
|
|
# content: it comes from the STACK_DIR repository variable (spec-v6 D15). An
|
|
# empty or malformed value would aim rsync at /dist/ on the remote host, so the
|
|
# job refuses it here — before any artifact download, before anything reaches the
|
|
# server — exactly like the site-identity check refuses a missing SITE_URL.
|
|
- name: Check stack directory
|
|
env:
|
|
STACK_DIR: ${{ vars.STACK_DIR }}
|
|
run: |
|
|
case "$STACK_DIR" in
|
|
/*) ;;
|
|
*)
|
|
echo "::error::STACK_DIR is not an absolute path — add it as a repository variable (Settings → Secrets and variables → Variables), value: the Dockge stack directory, e.g. /opt/stacks/dong-site"
|
|
exit 1
|
|
;;
|
|
esac
|
|
case "$STACK_DIR" in
|
|
*/)
|
|
echo "::error::STACK_DIR must not end with / — this job appends /dist/ itself"
|
|
exit 1
|
|
;;
|
|
esac
|
|
echo "Deploy target: $STACK_DIR/dist/"
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: static-site
|
|
path: dist/
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: resume-pdf-en
|
|
path: dist/
|
|
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: resume-pdf-vi
|
|
path: dist/
|
|
|
|
- name: rsync deployments
|
|
uses: burnett01/rsync-deployments@v9
|
|
with:
|
|
debug: true
|
|
switches: -avzr --delete
|
|
path: dist/
|
|
remote_path: ${{ vars.STACK_DIR }}/dist/
|
|
remote_host: ${{ secrets.DEPLOY_HOST }}
|
|
remote_port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
|
remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|