Automatiseer productie-deploy als opt-in stap naast de bestaande testdeploy

Voegt build-production en deploy-production jobs toe aan
continuous_integration.yaml, alleen actief bij een handmatige
workflow_dispatch-run met het deploy_production-vinkje aangevinkt (nooit
automatisch bij een push naar master). Een aparte build-production job is
nodig omdat VITE_APP_ENV een build-time Vite-variabele is: dezelfde bundel
kan niet zowel als test als production getagd zijn in Sentry/analytics.
Uploadpad komt uit de nieuwe Gitea-variable DEPLOY_PATH_PRODUCTION, analoog
aan DEPLOY_PATH_TEST. Documentatie en production-readiness-checklist
bijgewerkt om dit open item als opgelost te markeren.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-27 12:05:19 +02:00
co-authored by Claude Sonnet 5
parent 78f68d52f7
commit a208aebae0
4 changed files with 122 additions and 24 deletions
+87 -3
View File
@@ -1,6 +1,11 @@
name: Continuous Integration
on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
deploy_production:
description: 'Na een succesvolle build/test ook naar productie deployen (naast de automatische testdeploy)?'
type: boolean
default: false
pull_request:
types: [opened, synchronize, reopened]
push:
@@ -16,6 +21,7 @@ env:
NODE_VERSION: '20'
PNPM_VERSION: '9'
ARTIFACT_NAME: dist
ARTIFACT_NAME_PRODUCTION: dist-production
ARTIFACT_PATH: dist/
DEPLOY_ENVIRONMENT: test
# Niet hardcoded: DEPLOY_PATH komt uit een Gitea Actions repository variable
@@ -23,6 +29,8 @@ env:
# aangepast kan worden zonder de workflow zelf te wijzigen. Zie
# deployment-instructions.md voor de eenmalige setup van deze variable.
DEPLOY_PATH: ${{ vars.DEPLOY_PATH_TEST }}
DEPLOY_ENVIRONMENT_PRODUCTION: production
DEPLOY_PATH_PRODUCTION: ${{ vars.DEPLOY_PATH_PRODUCTION }}
jobs:
# Geeft de env-variabelen hierboven door als job-outputs, zodat ze ook
@@ -33,14 +41,20 @@ jobs:
runs-on: ubuntu-latest
outputs:
artifact_name: ${{ steps.set.outputs.artifact_name }}
artifact_name_production: ${{ steps.set.outputs.artifact_name_production }}
deploy_environment: ${{ steps.set.outputs.deploy_environment }}
deploy_path: ${{ steps.set.outputs.deploy_path }}
deploy_environment_production: ${{ steps.set.outputs.deploy_environment_production }}
deploy_path_production: ${{ steps.set.outputs.deploy_path_production }}
steps:
- id: set
run: |
echo "artifact_name=${{ env.ARTIFACT_NAME }}" >> "$GITHUB_OUTPUT"
echo "artifact_name_production=${{ env.ARTIFACT_NAME_PRODUCTION }}" >> "$GITHUB_OUTPUT"
echo "deploy_environment=${{ env.DEPLOY_ENVIRONMENT }}" >> "$GITHUB_OUTPUT"
echo "deploy_path=${{ env.DEPLOY_PATH }}" >> "$GITHUB_OUTPUT"
echo "deploy_environment_production=${{ env.DEPLOY_ENVIRONMENT_PRODUCTION }}" >> "$GITHUB_OUTPUT"
echo "deploy_path_production=${{ env.DEPLOY_PATH_PRODUCTION }}" >> "$GITHUB_OUTPUT"
prepare:
runs-on: ubuntu-latest
@@ -106,8 +120,9 @@ jobs:
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }}
# Build-time tag die bepaalt of dev/test-only UI (zoals de tijdelijke
# SentryTestButton) zichtbaar is; zie src/components/SentryTestButton.tsx.
# Zolang er nog geen aparte productie-build/deploy bestaat, is dit altijd
# gelijk aan DEPLOY_ENVIRONMENT ('test').
# Dit is de testomgeving-build, dus altijd gelijk aan DEPLOY_ENVIRONMENT
# ('test'). Zie de build-production job hieronder voor de aparte
# productie-build met VITE_APP_ENV=production.
VITE_APP_ENV: ${{ env.DEPLOY_ENVIRONMENT }}
run: pnpm run build
@@ -118,6 +133,59 @@ jobs:
path: ${{ env.ARTIFACT_PATH }}
retention-days: 1
# Aparte build voor productie, alleen nodig/gedraaid als deploy_production
# is aangevinkt bij een handmatige workflow_dispatch-run. Dit bestaat naast
# de gewone `build`-job (in plaats van die job te hergebruiken) omdat
# VITE_APP_ENV een build-time Vite-variabele is: één en dezelfde dist/-bundel
# kan niet zowel als 'test' als 'production' getagd zijn. Zonder deze aparte
# build zou de test-bundel (met environment: test) naar productie
# gedeployed worden, wat Sentry-events/analytics verkeerd zou taggen.
build-production:
needs: prepare
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_production == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
env:
# Zelfde Umami/Sentry-variabelen als de testbuild hierboven, want er
# is (nog) geen apart productie-Umami-website-ID of -Sentry-project
# gekozen. Splits deze pas op zodra dat nodig blijkt.
VITE_UMAMI_SCRIPT_URL: ${{ vars.VITE_UMAMI_SCRIPT_URL }}
VITE_UMAMI_WEBSITE_ID: ${{ vars.VITE_UMAMI_WEBSITE_ID }}
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }}
VITE_APP_ENV: ${{ env.DEPLOY_ENVIRONMENT_PRODUCTION }}
run: pnpm run build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME_PRODUCTION }}
path: ${{ env.ARTIFACT_PATH }}
retention-days: 1
test:
needs: build
runs-on: ubuntu-latest
@@ -163,3 +231,19 @@ jobs:
artifact_name: ${{ needs.config.outputs.artifact_name }}
environment: ${{ needs.config.outputs.deploy_environment }}
deploy_path: ${{ needs.config.outputs.deploy_path }}
# Productie-deploy is bewust NIET automatisch bij elke push naar master
# (in tegenstelling tot deploy-test hierboven): dit is pas een expliciete,
# bewuste actie via workflow_dispatch met het "deploy_production"-vinkje
# aangevinkt. Zo blijft de bestaande testdeploy-flow ongewijzigd en kan
# niemand per ongeluk productie deployen door simpelweg naar master te
# pushen of de workflow handmatig te starten zonder dat vinkje.
deploy-production:
needs: [build-production, test, config]
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_production == 'true'
uses: ./.gitea/workflows/deploy.yaml
secrets: inherit
with:
artifact_name: ${{ needs.config.outputs.artifact_name_production }}
environment: ${{ needs.config.outputs.deploy_environment_production }}
deploy_path: ${{ needs.config.outputs.deploy_path_production }}