Files

55 lines
2.2 KiB
YAML

# Production release. Triggered by pushing a version tag (v*). Pushing the tag IS the
# deliberate human gate. It promotes the images already built for that commit on the default
# branch (no rebuild) to the version tag, then deploys them to PRODUCTION.
#
# The tagged commit must already have been built on the default branch (build-and-stage),
# so its sha-<short> images exist; otherwise promotion fails with a clear error.
#
# Prerequisites: REGISTRY_TOKEN secret (PAT with write:package; the automatic GITEA_TOKEN is
# not authorized to push packages), plus prod secrets PROD_SSH_HOST, PROD_SSH_USER, PROD_SSH_KEY
# (the deploy user's forced-command wrapper on the host owns the checkout path), and optionally
# PROD_SSH_PORT if the host's sshd doesn't listen on the default port 22.
name: release-prod
on:
push:
tags: ["v*"]
jobs:
promote-and-deploy:
runs-on: [self-hosted]
steps:
- uses: actions/checkout@v4
- name: Compute registry + tags
id: meta
run: |
host="$(echo "${{ github.server_url }}" | sed -E 's#^https?://##')"
owner="${{ github.repository_owner }}"
echo "host=$host" >>"$GITHUB_OUTPUT"
# OCI repository paths must be lowercase; Gitea maps the lowercased owner back.
echo "registry=$host/${owner,,}" >>"$GITHUB_OUTPUT"
echo "src_tag=sha-$(git rev-parse --short HEAD)" >>"$GITHUB_OUTPUT"
echo "dst_tag=${{ github.ref_name }}" >>"$GITHUB_OUTPUT"
- name: Registry login
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" \
| docker login "${{ steps.meta.outputs.host }}" -u "${{ github.actor }}" --password-stdin
- name: Promote images (no rebuild)
env:
REGISTRY: ${{ steps.meta.outputs.registry }}
SRC_TAG: ${{ steps.meta.outputs.src_tag }}
DST_TAG: ${{ steps.meta.outputs.dst_tag }}
run: bash dev/ci/promote.sh
- name: Deploy to production
env:
DEPLOY_HOST: ${{ secrets.PROD_SSH_HOST }}
DEPLOY_USER: ${{ secrets.PROD_SSH_USER }}
DEPLOY_SSH_KEY: ${{ secrets.PROD_SSH_KEY }}
DEPLOY_SSH_PORT: ${{ secrets.PROD_SSH_PORT }}
IMAGE_TAG: ${{ steps.meta.outputs.dst_tag }}
run: bash dev/ci/deploy.sh