All checks were successful
dev - build & deploy naar test / build-and-deploy (push) Successful in 8s
- Nieuw bestand VERSION (repo-root) is nu de enige bron voor het versienummer; CI leest dit uit en geeft het door als APP_VERSION i.p.v. het opake dev-<sha> van de vorige build - dev-deploys tonen voortaan "v0.2.10-beta" i.p.v. "dev-<sha> · beta"; productie blijft het releaselabel tonen - Git-sha blijft beschikbaar via /api/version (nieuw veld "sha") en als hover-title op het versietagje, voor support/debug - Dockerfile/CI-workflows (dev + release) geven de git-sha nu als apart APP_ARG mee Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
52 lines
2.3 KiB
YAML
52 lines
2.3 KiB
YAML
name: release - build & deploy naar productie
|
|
|
|
# Draait wanneer je in Forgejo een release publiceert.
|
|
# De release-tag (bv. v1.2.0) wordt de image-tag op productie.
|
|
on:
|
|
release:
|
|
types: [published]
|
|
|
|
concurrency:
|
|
group: deploy-prod
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: prod # jouw prod-runner (productieserver)
|
|
env:
|
|
REGISTRY: ${{ vars.REGISTRY }}
|
|
IMAGE_NAME: ${{ github.repository }} # bes-r/teach
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Image-tags bepalen
|
|
id: meta
|
|
run: |
|
|
IMAGE="${REGISTRY}/${IMAGE_NAME}"
|
|
VERSION="${GITHUB_REF_NAME}" # de release-/tagnaam, bv. v1.2.0
|
|
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
|
|
echo "version_tag=${IMAGE}:${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "latest_tag=${IMAGE}:latest" >> "$GITHUB_OUTPUT"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
# Platte docker build/push (HTTP-registry, zie README voor insecure-registry).
|
|
- name: Login, build & push
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
|
docker build \
|
|
--build-arg APP_VERSION="${{ steps.meta.outputs.version }}" \
|
|
--build-arg GIT_SHA="${GITHUB_SHA::7}" \
|
|
-t "${{ steps.meta.outputs.version_tag }}" \
|
|
-t "${{ steps.meta.outputs.latest_tag }}" .
|
|
docker push "${{ steps.meta.outputs.version_tag }}"
|
|
docker push "${{ steps.meta.outputs.latest_tag }}"
|
|
|
|
# Deploy via gewone ssh (geen externe action nodig).
|
|
- name: Deploy naar productie-VM
|
|
run: |
|
|
echo "${{ secrets.PROD_SSH_KEY }}" > deploy_key
|
|
chmod 600 deploy_key
|
|
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=15 \
|
|
-i deploy_key ${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }} \
|
|
"set -e && cd ${{ secrets.PROD_DEPLOY_PATH }} && echo '${{ secrets.REGISTRY_TOKEN }}' | docker login ${{ vars.REGISTRY }} -u '${{ secrets.REGISTRY_USER }}' --password-stdin && sed -i 's|^IMAGE=.*|IMAGE=${{ steps.meta.outputs.version_tag }}|' .env && docker compose -f compose.deploy.yaml pull app && docker compose -f compose.deploy.yaml up -d && docker image prune -f"
|
|
rm -f deploy_key
|