mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20: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.
103 lines
4.1 KiB
YAML
103 lines
4.1 KiB
YAML
name: Redeploy Nginx
|
|
|
|
# Infra files only (spec-v4-deploy-infra D1): a change to the nginx template,
|
|
# the compose definition, or the Basic-auth file redeploys the container —
|
|
# content commits never do. workflow_dispatch is the token-rotation runbook.
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
paths:
|
|
- nginx.conf
|
|
- compose.yaml
|
|
- deploy/htpasswd
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: deploy-infra
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
redeploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
# Ship exactly the three triggered files. Never .env, never secrets/ (D6).
|
|
# The action builds the rsync source as "$GITHUB_WORKSPACE/$path" and passes
|
|
# it as one argument (entrypoint.sh) — so NO --relative: -R mirrors the whole
|
|
# absolute workspace path onto the server (run 2026-10-23 created
|
|
# dong-site/workspace/dong.nguyen/cv/… on the VPS). Plain -avz lands each
|
|
# file's basename in remote_path; the htpasswd step names deploy/ itself.
|
|
- name: Sync nginx.conf
|
|
uses: burnett01/rsync-deployments@v9
|
|
with:
|
|
switches: -avz
|
|
path: nginx.conf
|
|
remote_path: /opt/stacks/dong-site/
|
|
remote_host: ${{ secrets.DEPLOY_HOST }}
|
|
remote_port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
|
remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|
|
- name: Sync compose.yaml
|
|
uses: burnett01/rsync-deployments@v9
|
|
with:
|
|
switches: -avz
|
|
path: compose.yaml
|
|
remote_path: /opt/stacks/dong-site/
|
|
remote_host: ${{ secrets.DEPLOY_HOST }}
|
|
remote_port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
|
remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|
|
- name: Sync deploy/htpasswd
|
|
uses: burnett01/rsync-deployments@v9
|
|
with:
|
|
switches: -avz
|
|
path: deploy/htpasswd
|
|
remote_path: /opt/stacks/dong-site/deploy/
|
|
remote_host: ${{ secrets.DEPLOY_HOST }}
|
|
remote_port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
|
remote_key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|
|
|
|
# Test-before-touch (D3): the throwaway container runs the same entrypoint
|
|
# render pipeline as production, with placeholder values — nginx -t checks
|
|
# syntax only, so the real token never enters this container or the job.
|
|
# A failure here fails the job; the live container keeps serving.
|
|
- name: Test new config
|
|
uses: appleboy/ssh-action@v1.2.0
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|
|
script: |
|
|
cd /opt/stacks/dong-site
|
|
docker run --rm \
|
|
-v "$PWD/nginx.conf:/etc/nginx/templates/default.conf.template:ro" \
|
|
-v "$PWD/deploy/htpasswd:/etc/nginx/htpasswd:ro" \
|
|
-e CONTENT_API_TOKEN=placeholder \
|
|
-e CONTENT_API_BASE=http://127.0.0.1:1 \
|
|
-e 'NGINX_ENVSUBST_FILTER=CONTENT_API_TOKEN|CONTENT_API_BASE' \
|
|
nginx:alpine nginx -t
|
|
|
|
# Apply + verify (D4): recreate is the same command the Dockge deploy
|
|
# button runs. The health probe uses wget because nginx:alpine carries no
|
|
# curl; on failure the job prints the container log and fails.
|
|
- name: Recreate and probe
|
|
uses: appleboy/ssh-action@v1.2.0
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
port: ${{ secrets.DEPLOY_SSH_PORT }}
|
|
username: ${{ secrets.DEPLOY_USER }}
|
|
key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
|
|
script: |
|
|
cd /opt/stacks/dong-site
|
|
docker compose up -d --force-recreate dong-site
|
|
sleep 2
|
|
if ! docker exec dong-site wget -q -O /dev/null http://127.0.0.1/; then
|
|
docker logs --tail 50 dong-site
|
|
exit 1
|
|
fi
|
|
docker exec dong-site nginx -t
|