thermograph/.forgejo/workflows/frontend-deploy.yml
emi af839c6cd0
All checks were successful
secrets-guard / encrypted (push) Successful in 6s
PR build (required check) / changes (pull_request) Successful in 6s
secrets-guard / encrypted (pull_request) Successful in 5s
PR build (required check) / build-frontend (pull_request) Has been skipped
PR build (required check) / validate-observability (pull_request) Has been skipped
PR build (required check) / build-backend (pull_request) Successful in 42s
PR build (required check) / gate (pull_request) Successful in 3s
Finish the domain-sha tag keying: three deploy workflows were missed (#6)
2026-07-23 13:58:57 +00:00

70 lines
2.8 KiB
YAML

name: Deploy frontend to beta VPS
# On a push to `main` that touches frontend/**, SSH to beta and roll ONLY the
# frontend service onto the image frontend-build-push.yml just published for
# this commit. Backend is deployed independently by backend-deploy.yml --
# the FE/BE CI-CD split survives reunification intact: a frontend change ships
# without touching backend and vice versa. infra/deploy/deploy.sh persists
# each service's live tag host-side, so a single-service roll never disturbs
# the other. An infra-only push rolls nothing (infra-sync.yml syncs the
# host checkouts instead); a mixed frontend+backend push fires both deploy
# workflows, serialized host-side by deploy.sh's flock.
#
# The SSH_HOST/USER/KEY/PORT secrets point at beta. appleboy/ssh-action is
# referenced by full GitHub URL because it isn't mirrored in Forgejo's default
# action registry.
#
# The tag MUST match frontend-build-push.yml's last-frontend-commit key (12
# hex), not the full 40-char ${{ github.sha }} -- default Actions expressions
# have no substring function, so the compute step below truncates it.
# deploy.sh also retries the pull for ~5 min because Forgejo `needs:` can't
# gate across the separate build-push workflow, so this push's build may still
# be in flight.
#
# Frontend's own register() fetches the IndexNow key from backend at boot, so
# deploy.sh waits on a healthy backend before declaring the frontend roll OK
# (its compose depends_on already encodes that ordering).
on:
push:
branches: [main]
paths: ['frontend/**']
workflow_dispatch: {}
concurrency:
group: beta-deploy-frontend
cancel-in-progress: false
jobs:
deploy:
runs-on: docker
steps:
- uses: actions/checkout@v4
# fetch-depth 0: the tag is keyed to the LAST COMMIT THAT TOUCHED THIS
# DOMAIN, not the branch tip -- in a path-filtered monorepo the tip is
# often an unrelated domain's commit, and a depth-1 clone can't see
# past it to find the real key.
with:
fetch-depth: 0
- name: Compute image tag (last frontend-touching commit)
id: tag
run: |
domain_sha="$(git log -1 --format=%H -- frontend/)"
echo "tag=sha-${domain_sha:0:12}" >> "$GITHUB_OUTPUT"
- name: Deploy frontend over SSH
uses: https://github.com/appleboy/ssh-action@v1.2.0
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
# Forward the target service + the image tag to run. deploy.sh reads
# FRONTEND_IMAGE_TAG and rolls just `frontend`.
envs: SERVICE,FRONTEND_IMAGE_TAG
script: /opt/thermograph/infra/deploy/deploy.sh
env:
SERVICE: frontend
FRONTEND_IMAGE_TAG: ${{ steps.tag.outputs.tag }}