Merge pull request 'CI: nieuwe Gitea-namen en SSH-sleutel i.p.v. wachtwoord' (#34) from ci/ssh-key-new-names into master
Continuous Integration / config-sls (push) Successful in 7s
Continuous Integration / config-asf (push) Successful in 6s
Continuous Integration / changes (push) Successful in 14s
Continuous Integration / backend-build (push) Successful in 2m46s
Continuous Integration / vulnerability-scan (push) Successful in 3m15s
Continuous Integration / frontend-prepare (push) Successful in 34s
Continuous Integration / frontend-build (push) Successful in 58s
Continuous Integration / backend-test (push) Successful in 4m46s
Continuous Integration / frontend-test (push) Successful in 3m2s
Continuous Integration / compile-sites (push) Successful in 12m14s
Continuous Integration / frontend-lint (push) Failing after 10m48s
Continuous Integration / publish-sls-test (push) Skipped
Continuous Integration / publish-sls-production (push) Skipped
Continuous Integration / deploy-sls-test (push) Skipped
Continuous Integration / deploy-sls-production (push) Skipped
Continuous Integration / publish-asf-test (push) Skipped
Continuous Integration / deploy-asf-test (push) Skipped
Continuous Integration / smoke-sls-test (push) Skipped
Continuous Integration / smoke-asf-test (push) Skipped

This commit was merged in pull request #34.
This commit is contained in:
2026-11-18 21:11:53 +01:00
4 changed files with 123 additions and 135 deletions
+50 -51
View File
@@ -42,12 +42,12 @@ env:
ARTIFACT_NAME_SLS_PRODUCTION: app-sls-production
DEPLOY_ENVIRONMENT_SLS_TEST: test
DEPLOY_ENVIRONMENT_SLS_PRODUCTION: production
DEPLOY_PATH_TEST: ${{ vars.DEPLOY_PATH_TEST }}
DEPLOY_PATH_PRODUCTION: ${{ vars.DEPLOY_PATH_PRODUCTION }}
SERVICE_NAME_TEST: ${{ vars.SERVICE_NAME_TEST }}
SERVICE_NAME_PRODUCTION: ${{ vars.SERVICE_NAME_PRODUCTION }}
HEALTH_CHECK_URL_TEST: ${{ vars.HEALTH_CHECK_URL_TEST }}
HEALTH_CHECK_URL_PRODUCTION: ${{ vars.HEALTH_CHECK_URL_PRODUCTION }}
DEPLOY_PATH_TEST: ${{ vars.SLS_TEST_DEPLOY_PATH }}
DEPLOY_PATH_PRODUCTION: ${{ vars.SLS_PROD_DEPLOY_PATH }}
SERVICE_NAME_TEST: ${{ vars.SLS_TEST_SERVICE_NAME }}
SERVICE_NAME_PRODUCTION: ${{ vars.SLS_PROD_SERVICE_NAME }}
HEALTH_CHECK_URL_TEST: ${{ vars.SLS_TEST_HEALTH_URL }}
HEALTH_CHECK_URL_PRODUCTION: ${{ vars.SLS_PROD_HEALTH_URL }}
jobs:
# Passes the env: values above through as job outputs, since the env context is unavailable in
@@ -78,16 +78,16 @@ jobs:
# step-level env works on both runners. The test trio must be set, otherwise fail here instead of in the deploy.
- id: set
env:
DEPLOY_PATH_TEST: ${{ vars.DEPLOY_PATH_TEST }}
DEPLOY_PATH_PRODUCTION: ${{ vars.DEPLOY_PATH_PRODUCTION }}
SERVICE_NAME_TEST: ${{ vars.SERVICE_NAME_TEST }}
SERVICE_NAME_PRODUCTION: ${{ vars.SERVICE_NAME_PRODUCTION }}
HEALTH_CHECK_URL_TEST: ${{ vars.HEALTH_CHECK_URL_TEST }}
HEALTH_CHECK_URL_PRODUCTION: ${{ vars.HEALTH_CHECK_URL_PRODUCTION }}
DEPLOY_PATH_TEST: ${{ vars.SLS_TEST_DEPLOY_PATH }}
DEPLOY_PATH_PRODUCTION: ${{ vars.SLS_PROD_DEPLOY_PATH }}
SERVICE_NAME_TEST: ${{ vars.SLS_TEST_SERVICE_NAME }}
SERVICE_NAME_PRODUCTION: ${{ vars.SLS_PROD_SERVICE_NAME }}
HEALTH_CHECK_URL_TEST: ${{ vars.SLS_TEST_HEALTH_URL }}
HEALTH_CHECK_URL_PRODUCTION: ${{ vars.SLS_PROD_HEALTH_URL }}
run: |
for v in DEPLOY_PATH_TEST SERVICE_NAME_TEST HEALTH_CHECK_URL_TEST; do
if [ -z "${!v}" ]; then
echo "The Gitea variable $v is empty or not set on this runner; the deploy would use an empty path."
echo "The value for $v (a SLS_TEST_* Gitea variable) is empty or not set on this runner; the deploy would use an empty path."
exit 1
fi
done
@@ -418,11 +418,11 @@ jobs:
version: ${{ env.PNPM_VERSION }}
- name: Verify Umami origin is permitted (REF-U5-01)
if: ${{ vars.VITE_UMAMI_SCRIPT_URL != '' }}
if: ${{ vars.SLS_TEST_UMAMI_SCRIPT_URL != '' }}
run: |
ORIGIN=$(echo "${{ vars.VITE_UMAMI_SCRIPT_URL }}" | sed -E 's#^(https?://[^/]+).*#\1#')
if ! echo ",${{ vars.SECURITY_ALLOWED_SCRIPT_ORIGINS_TEST }}," | grep -qF ",$ORIGIN,"; then
echo "Umami origin '$ORIGIN' is not present in the SECURITY_ALLOWED_SCRIPT_ORIGINS_TEST Gitea variable."
ORIGIN=$(echo "${{ vars.SLS_TEST_UMAMI_SCRIPT_URL }}" | sed -E 's#^(https?://[^/]+).*#\1#')
if ! echo ",${{ vars.SLS_TEST_SECURITY_ALLOWED_SCRIPT_ORIGINS }}," | grep -qF ",$ORIGIN,"; then
echo "Umami origin '$ORIGIN' is not present in the SLS_TEST_SECURITY_ALLOWED_SCRIPT_ORIGINS Gitea variable."
echo "Fix the variable, or the test environment's SecurityHeaders CSP config it must mirror (D-16)."
exit 1
fi
@@ -441,9 +441,9 @@ jobs:
VITE_APP_ENV: test
VITE_APP_TITLE: SLP Software
VITE_THEME: slpsoftware
VITE_UMAMI_SCRIPT_URL: ${{ vars.VITE_UMAMI_SCRIPT_URL }}
VITE_UMAMI_WEBSITE_ID: ${{ vars.VITE_UMAMI_WEBSITE_ID_TEST }}
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }}
VITE_UMAMI_SCRIPT_URL: ${{ vars.SLS_TEST_UMAMI_SCRIPT_URL }}
VITE_UMAMI_WEBSITE_ID: ${{ vars.SLS_TEST_UMAMI_WEBSITE_ID }}
VITE_SENTRY_DSN: ${{ vars.SLS_TEST_SENTRY_DSN }}
run: |
pnpm install --frozen-lockfile
pnpm build
@@ -496,11 +496,11 @@ jobs:
version: ${{ env.PNPM_VERSION }}
- name: Verify Umami origin is permitted (REF-U5-01)
if: ${{ vars.VITE_UMAMI_SCRIPT_URL != '' }}
if: ${{ vars.SLS_PROD_UMAMI_SCRIPT_URL != '' }}
run: |
ORIGIN=$(echo "${{ vars.VITE_UMAMI_SCRIPT_URL }}" | sed -E 's#^(https?://[^/]+).*#\1#')
if ! echo ",${{ vars.SECURITY_ALLOWED_SCRIPT_ORIGINS_PRODUCTION }}," | grep -qF ",$ORIGIN,"; then
echo "Umami origin '$ORIGIN' is not present in the SECURITY_ALLOWED_SCRIPT_ORIGINS_PRODUCTION Gitea variable."
ORIGIN=$(echo "${{ vars.SLS_PROD_UMAMI_SCRIPT_URL }}" | sed -E 's#^(https?://[^/]+).*#\1#')
if ! echo ",${{ vars.SLS_PROD_SECURITY_ALLOWED_SCRIPT_ORIGINS }}," | grep -qF ",$ORIGIN,"; then
echo "Umami origin '$ORIGIN' is not present in the SLS_PROD_SECURITY_ALLOWED_SCRIPT_ORIGINS Gitea variable."
echo "Fix the variable, or the production environment's SecurityHeaders CSP config it must mirror (D-16)."
exit 1
fi
@@ -513,9 +513,9 @@ jobs:
VITE_APP_ENV: production
VITE_APP_TITLE: SLP Software
VITE_THEME: slpsoftware
VITE_UMAMI_SCRIPT_URL: ${{ vars.VITE_UMAMI_SCRIPT_URL }}
VITE_UMAMI_WEBSITE_ID: ${{ vars.VITE_UMAMI_WEBSITE_ID_PRODUCTION }}
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN }}
VITE_UMAMI_SCRIPT_URL: ${{ vars.SLS_PROD_UMAMI_SCRIPT_URL }}
VITE_UMAMI_WEBSITE_ID: ${{ vars.SLS_PROD_UMAMI_WEBSITE_ID }}
VITE_SENTRY_DSN: ${{ vars.SLS_PROD_SENTRY_DSN }}
run: |
pnpm install --frozen-lockfile
pnpm build
@@ -549,11 +549,12 @@ jobs:
uses: ./.gitea/workflows/deploy-scp.yaml
secrets: inherit
with:
host: SLS_TEST
artifact_name: ${{ needs.config-sls.outputs.artifact_name_sls_test }}
environment: ${{ needs.config-sls.outputs.deploy_environment_sls_test }}
deploy_path: ${{ vars.DEPLOY_PATH_TEST }}
service_name: ${{ vars.SERVICE_NAME_TEST }}
health_check_url: ${{ vars.HEALTH_CHECK_URL_TEST }}
deploy_path: ${{ vars.SLS_TEST_DEPLOY_PATH }}
service_name: ${{ vars.SLS_TEST_SERVICE_NAME }}
health_check_url: ${{ vars.SLS_TEST_HEALTH_URL }}
run_db_backup: false
# Production deploy ONLY on an explicit workflow_dispatch run with deploy_sls_production checked, and
@@ -566,11 +567,12 @@ jobs:
uses: ./.gitea/workflows/deploy-scp.yaml
secrets: inherit
with:
host: SLS_PROD
artifact_name: ${{ needs.config-sls.outputs.artifact_name_sls_production }}
environment: ${{ needs.config-sls.outputs.deploy_environment_sls_production }}
deploy_path: ${{ vars.DEPLOY_PATH_PRODUCTION }}
service_name: ${{ vars.SERVICE_NAME_PRODUCTION }}
health_check_url: ${{ vars.HEALTH_CHECK_URL_PRODUCTION }}
deploy_path: ${{ vars.SLS_PROD_DEPLOY_PATH }}
service_name: ${{ vars.SLS_PROD_SERVICE_NAME }}
health_check_url: ${{ vars.SLS_PROD_HEALTH_URL }}
run_db_backup: true
# ==========================================================================================
@@ -578,15 +580,12 @@ jobs:
# SlpSoftware jobs, the env block, deploy-scp.yaml) is changed, a failure here never blocks the
# SlpSoftware deploy and vice versa.
#
# Everything below is switched on by ONE Gitea variable, ASF_TEST_DEPLOY_ENABLED == 'true'.
# While it is unset (or anything else) all three jobs are skipped and the pipeline behaves
# exactly as before. Secrets cannot be tested in an `if:`, hence an explicit variable; it is set
# only after the Pi and the other ASF_* variables exist.
# No switch: the ASF test deploy runs like the SlpSoftware one. The Gitea variables ASF_TEST_DEPLOY_PATH,
# ASF_TEST_SERVICE_NAME and ASF_TEST_HEALTH_URL and the secrets ASF_TEST_HOST_* must exist; config-asf fails clearly if not.
# Runs: on every push to master (like the SlpSoftware test deploy) or manually with the
# "Deploy ASF test" box ticked. Test only: there is no production path for ASF.
# ==========================================================================================
config-asf:
if: ${{ vars.ASF_TEST_DEPLOY_ENABLED == 'true' }}
runs-on: linux
outputs:
deploy_path: ${{ steps.set.outputs.deploy_path }}
@@ -595,13 +594,13 @@ jobs:
steps:
- id: set
env:
DEPLOY_PATH: ${{ vars.DEPLOY_PATH_ASF_TEST }}
SERVICE_NAME: ${{ vars.SERVICE_NAME_ASF_TEST }}
HEALTH_CHECK_URL: ${{ vars.HEALTH_CHECK_URL_ASF_TEST }}
DEPLOY_PATH: ${{ vars.ASF_TEST_DEPLOY_PATH }}
SERVICE_NAME: ${{ vars.ASF_TEST_SERVICE_NAME }}
HEALTH_CHECK_URL: ${{ vars.ASF_TEST_HEALTH_URL }}
run: |
for v in DEPLOY_PATH SERVICE_NAME HEALTH_CHECK_URL; do
if [ -z "${!v}" ]; then
echo "The Gitea variable for $v (…_ASF_TEST) is not set; set it or switch ASF_TEST_DEPLOY_ENABLED off."
echo "The Gitea variable for $v (ASF_TEST_*) is not set."
exit 1
fi
done
@@ -612,10 +611,9 @@ jobs:
publish-asf-test:
needs: [changes, backend-build, backend-test, vulnerability-scan, frontend-build, frontend-test, frontend-lint]
# Same gate handling as publish-sls-test (see there for why always() and explicit results), plus the
# ASF switch, and built only when it will actually be deployed.
# fact that it is built only when it will actually be deployed.
if: |
always() &&
vars.ASF_TEST_DEPLOY_ENABLED == 'true' &&
needs.changes.result == 'success' &&
needs.backend-build.result != 'failure' && needs.backend-build.result != 'cancelled' &&
needs.backend-test.result != 'failure' && needs.backend-test.result != 'cancelled' &&
@@ -648,7 +646,7 @@ jobs:
VITE_APP_TITLE: Andrea Slop Fotografie
VITE_THEME: asf
VITE_DEFAULT_LANGUAGE: nl
VITE_SENTRY_DSN: ${{ vars.VITE_SENTRY_DSN_ASF }}
VITE_SENTRY_DSN: ${{ vars.ASF_TEST_SENTRY_DSN }}
run: |
pnpm install --frozen-lockfile
pnpm build
@@ -672,15 +670,16 @@ jobs:
# here the deploy account name in the path, arrives empty). config-asf still validates that they are set.
deploy-asf-test:
needs: [publish-asf-test, config-asf]
if: vars.ASF_TEST_DEPLOY_ENABLED == 'true' && ((github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_asf_test == 'true') || (github.event_name == 'push' && github.ref == 'refs/heads/master'))
if: ((github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_asf_test == 'true') || (github.event_name == 'push' && github.ref == 'refs/heads/master'))
uses: ./.gitea/workflows/deploy-scp.yaml
secrets: inherit
with:
host: ASF_TEST
artifact_name: app-asf-test
environment: test
deploy_path: ${{ vars.DEPLOY_PATH_ASF_TEST }}
service_name: ${{ vars.SERVICE_NAME_ASF_TEST }}
health_check_url: ${{ vars.HEALTH_CHECK_URL_ASF_TEST }}
deploy_path: ${{ vars.ASF_TEST_DEPLOY_PATH }}
service_name: ${{ vars.ASF_TEST_SERVICE_NAME }}
health_check_url: ${{ vars.ASF_TEST_HEALTH_URL }}
run_db_backup: false
# --- Smoke tests of the deployed compositions (anonymous requests, see scripts/smoke-site.sh) ---
@@ -694,7 +693,7 @@ jobs:
- uses: actions/checkout@v4
- name: Smoke test SLS test
env:
HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_TEST }}
HEALTH_URL: ${{ vars.SLS_TEST_HEALTH_URL }}
run: bash scripts/smoke-site.sh "$HEALTH_URL" sls-test
smoke-asf-test:
@@ -705,5 +704,5 @@ jobs:
- uses: actions/checkout@v4
- name: Smoke test ASF test
env:
HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_ASF_TEST }}
HEALTH_URL: ${{ vars.ASF_TEST_HEALTH_URL }}
run: bash scripts/smoke-site.sh "$HEALTH_URL" asf-test
+57 -65
View File
@@ -7,6 +7,10 @@ name: Deploy (SCP)
on:
workflow_call:
inputs:
host:
description: 'Which host to deploy to: the prefix of its secrets, one of SLS_TEST, SLS_PROD, ASF_TEST (<host>_HOST_ADDRESS, _PORT, _USERNAME, _SSH_KEY)'
required: true
type: string
artifact_name:
description: 'Build artifact to download and deploy'
required: true
@@ -45,70 +49,88 @@ jobs:
# Runner-independent: only installs what is missing, and only uses sudo when not already root and sudo exists
# (a container on the PC runner has neither sudo nor a need for it; the Pi runner may need it).
#
# Authentication: the Pi-Main host only allows password login from the Pi runner's address, so every runner other
# than that one needs a key. If the secret PI_MAIN_SSH_KEY (private key of the deploy account) is set and works,
# the wrappers `rssh` / `rscp` below use it (-i, IdentitiesOnly, BatchMode); otherwise they fall back to sshpass
# with the password, which keeps working from the Pi runner. The key lives in a temp directory that is removed
# at the end of the job; it is never printed.
# Authentication is by SSH key only (no password). The deploy key of the chosen host (<host>_HOST_SSH_KEY) is
# written to a temp directory with mode 600; the wrappers `rssh` / `rscp` below use it (-i, IdentitiesOnly,
# BatchMode, StrictHostKeyChecking=accept-new with a known_hosts file of this job only) and read the address,
# port and user of the chosen host from files in the same directory, so no other step needs the secrets. The
# directory is removed at the end of the job; the key is never printed.
#
# All twelve secrets are mapped here and the right group is chosen in the shell: an expression like
# `a && secrets.X || secrets.Y` would silently fall through to another host when a secret is empty.
- name: Ensure ssh tooling and authentication
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
SSH_KEY: ${{ secrets.PI_MAIN_SSH_KEY }}
TARGET: ${{ inputs.host }}
SLS_TEST_HOST_ADDRESS: ${{ secrets.SLS_TEST_HOST_ADDRESS }}
SLS_TEST_HOST_PORT: ${{ secrets.SLS_TEST_HOST_PORT }}
SLS_TEST_HOST_USERNAME: ${{ secrets.SLS_TEST_HOST_USERNAME }}
SLS_TEST_HOST_SSH_KEY: ${{ secrets.SLS_TEST_HOST_SSH_KEY }}
SLS_PROD_HOST_ADDRESS: ${{ secrets.SLS_PROD_HOST_ADDRESS }}
SLS_PROD_HOST_PORT: ${{ secrets.SLS_PROD_HOST_PORT }}
SLS_PROD_HOST_USERNAME: ${{ secrets.SLS_PROD_HOST_USERNAME }}
SLS_PROD_HOST_SSH_KEY: ${{ secrets.SLS_PROD_HOST_SSH_KEY }}
ASF_TEST_HOST_ADDRESS: ${{ secrets.ASF_TEST_HOST_ADDRESS }}
ASF_TEST_HOST_PORT: ${{ secrets.ASF_TEST_HOST_PORT }}
ASF_TEST_HOST_USERNAME: ${{ secrets.ASF_TEST_HOST_USERNAME }}
ASF_TEST_HOST_SSH_KEY: ${{ secrets.ASF_TEST_HOST_SSH_KEY }}
IN_DEPLOY_PATH: ${{ inputs.deploy_path }}
IN_SERVICE_NAME: ${{ inputs.service_name }}
IN_HEALTH_URL: ${{ inputs.health_check_url }}
run: |
# Inputs are not secret: print them so an empty one is visible, and stop before anything touches the host.
echo "Inputs: deploy_path='$IN_DEPLOY_PATH' service_name='$IN_SERVICE_NAME' health_check_url='$IN_HEALTH_URL'"
echo "Inputs: host='$TARGET' deploy_path='$IN_DEPLOY_PATH' service_name='$IN_SERVICE_NAME' health_check_url='$IN_HEALTH_URL'"
for v in IN_DEPLOY_PATH IN_SERVICE_NAME IN_HEALTH_URL; do
if [ -z "${!v}" ]; then echo "Input $v is empty; refusing to deploy."; exit 1; fi
done
case "$TARGET" in
SLS_TEST|SLS_PROD|ASF_TEST) ;;
*) echo "Unknown host '$TARGET' (expected SLS_TEST, SLS_PROD or ASF_TEST); refusing to deploy."; exit 1;;
esac
SSH_HOST_VALUE=$(printenv "${TARGET}_HOST_ADDRESS")
SSH_PORT_VALUE=$(printenv "${TARGET}_HOST_PORT")
SSH_USER_VALUE=$(printenv "${TARGET}_HOST_USERNAME")
SSH_KEY_VALUE=$(printenv "${TARGET}_HOST_SSH_KEY")
for n in HOST_ADDRESS HOST_PORT HOST_USERNAME HOST_SSH_KEY; do
if [ -z "$(printenv "${TARGET}_${n}")" ]; then echo "The secret ${TARGET}_${n} is empty or not set; refusing to deploy."; exit 1; fi
done
SUDO=""
if [ "$(id -u)" != "0" ] && command -v sudo >/dev/null 2>&1; then SUDO="sudo"; fi
if ! command -v sshpass >/dev/null 2>&1 || ! command -v ssh >/dev/null 2>&1 || ! command -v scp >/dev/null 2>&1; then
$SUDO apt-get update && $SUDO apt-get install -y sshpass openssh-client
if ! command -v ssh >/dev/null 2>&1 || ! command -v scp >/dev/null 2>&1; then
$SUDO apt-get update && $SUDO apt-get install -y openssh-client
fi
D=$(mktemp -d)
chmod 700 "$D"
mkdir -p "$D/bin"
echo "DEPLOY_TMP=$D" >> "$GITHUB_ENV"
echo "$D/bin" >> "$GITHUB_PATH"
if [ -n "$SSH_KEY" ]; then
printf '%s\n' "$SSH_KEY" > "$D/key"
printf '%s\n' "$SSH_KEY_VALUE" > "$D/key"
chmod 600 "$D/key"
if ssh -i "$D/key" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=15 \
-p "$SSH_PORT" "$SSH_USER@$SSH_HOST" true; then
touch "$D/key_ok"
echo "Authentication: deploy key"
else
echo "Deploy key rejected or host unreachable with it; falling back to password"
fi
else
echo "No deploy key set; using password"
fi
printf '%s' "$SSH_HOST_VALUE" > "$D/host"
printf '%s' "$SSH_PORT_VALUE" > "$D/port"
printf '%s' "$SSH_USER_VALUE" > "$D/user"
: > "$D/known_hosts"
cat > "$D/bin/rssh" <<'WRAP'
#!/bin/sh
D="$(dirname "$0")/.."
if [ -f "$D/key_ok" ]; then
exec ssh -i "$D/key" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=no -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "$@"
fi
exec sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "$@"
exec ssh -i "$D/key" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="$D/known_hosts" \
-p "$(cat "$D/port")" "$(cat "$D/user")@$(cat "$D/host")" "$@"
WRAP
cat > "$D/bin/rscp" <<'WRAP'
#!/bin/sh
# The remote side of a copy is written as @REMOTE@:<path>; it is replaced by user@host.
D="$(dirname "$0")/.."
if [ -f "$D/key_ok" ]; then
exec scp -i "$D/key" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=no -P "$SSH_PORT" "$@"
fi
exec sshpass -p "$SSH_PASS" scp -o StrictHostKeyChecking=no -P "$SSH_PORT" "$@"
REMOTE="$(cat "$D/user")@$(cat "$D/host")"
for a in "$@"; do shift; set -- "$@" "$(printf '%s' "$a" | sed "s|^@REMOTE@:|$REMOTE:|")"; done
exec scp -i "$D/key" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile="$D/known_hosts" \
-P "$(cat "$D/port")" "$@"
WRAP
chmod +x "$D/bin/rssh" "$D/bin/rscp"
# Connection check: fails the job here, with a clear message, instead of in the first real step.
if "$D/bin/rssh" true; then echo "Authentication: deploy key accepted by ${TARGET}"; else echo "The deploy key of ${TARGET} was rejected or the host is unreachable."; exit 1; fi
- name: Compute release timestamp
id: release
run: echo "timestamp=$(date -u +%Y%m%d%H%M%S)" >> "$GITHUB_OUTPUT"
@@ -128,11 +150,6 @@ jobs:
# literal, unresolved `${{ inputs.environment }}` text in the log.
- name: Back up database
if: ${{ inputs.run_db_backup }}
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
echo "Environment: ${{ inputs.environment }}"
rssh \
@@ -148,11 +165,6 @@ jobs:
# actions rely on (D-05). A plain scp command needs no nested container.
# Same Gitea Actions limitation as the step above — static name, value logged via echo instead.
- name: Upload release
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
echo "Environment: ${{ inputs.environment }}, transport: ${{ inputs.transport }}"
RELEASE_DIR="${{ inputs.deploy_path }}/releases/${{ steps.release.outputs.timestamp }}"
@@ -160,7 +172,7 @@ jobs:
"mkdir -p $RELEASE_DIR"
rscp \
-r ${{ inputs.artifact_name }}/* \
"$SSH_USER@$SSH_HOST:$RELEASE_DIR/"
"@REMOTE@:$RELEASE_DIR/"
# The customer's public website (wwwroot/web) must survive every CMS deploy (FR-08, ASM-01).
# It lives outside the swapped release directory in a persistent shared/ folder, and is
@@ -173,11 +185,6 @@ jobs:
# source project has one with actual content, so a release built before any frontend content
# exists can land with no wwwroot/ directory whatsoever, not merely an empty wwwroot/web/.
- name: Link persistent website content
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
RELEASE_DIR="${{ inputs.deploy_path }}/releases/${{ steps.release.outputs.timestamp }}"
rssh \
@@ -197,11 +204,6 @@ jobs:
# `ls ... 2>/dev/null` piped to a `while read` (rather than a bare glob loop) keeps this
# POSIX-sh safe and correct when shared/modules is empty, which is the common case today.
- name: Link persistent modules
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
RELEASE_DIR="${{ inputs.deploy_path }}/releases/${{ steps.release.outputs.timestamp }}"
rssh \
@@ -216,11 +218,6 @@ jobs:
# directory. The process is then restarted so it picks up the new assemblies — a running .NET
# process holds on to the ones it already loaded.
- name: Switch current release and restart service
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
RELEASE_DIR="${{ inputs.deploy_path }}/releases/${{ steps.release.outputs.timestamp }}"
rssh \
@@ -252,11 +249,6 @@ jobs:
# a re-point-and-restart away without rebuilding. Only runs after a passing health check —
# pruning after a failed check could leave the only other release as the sole survivor.
- name: Prune old releases
env:
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_PASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
run: |
rssh \
"cd ${{ inputs.deploy_path }}/releases && ls -1t | tail -n +3 | xargs -r rm -rf"
+1 -1
View File
@@ -355,7 +355,7 @@ Ontbreekt `wwwroot/web/` nog (een verse deployment vóórdat een website-workspa
Voor lokale ontwikkeling verandert er niets: `pnpm dev` blijft op `http://localhost:5173` draaien zonder `/admin`-prefix.
### 1. Build & Publish
Publiceren gebeurt via de Gitea Actions-pipeline (`.gitea/workflows/continuous_integration.yaml` → `deploy-scp.yaml`), niet met een losse handmatige `dotnet publish`-stap: elke push naar `master` deployt automatisch naar de SlpSoftware-testomgeving (en naar de ASF-testomgeving als de Gitea-variabele `ASF_TEST_DEPLOY_ENABLED` op `true` staat), productie alleen via een expliciete `workflow_dispatch` met de `deploy_production`-vlag aan. Een branch naar test deployen kan met een handmatige run (`deploy_test` en/of `deploy_asf_test`). Zie [`docs/deploy-en-testomgevingen.md`](docs/deploy-en-testomgevingen.md) voor invoer, testhosts, vereiste variabelen en secrets (alleen namen) en rollback. De pipeline publiceert framework-dependent voor `linux-arm64` en bouwt daarbij automatisch ook de admin-frontend mee naar `wwwroot/admin/`.
Publiceren gebeurt via de Gitea Actions-pipeline (`.gitea/workflows/continuous_integration.yaml` → `deploy-scp.yaml`), niet met een losse handmatige `dotnet publish`-stap: elke push naar `master` deployt automatisch naar de SlpSoftware-testomgeving (en ook naar de ASF-testomgeving), productie alleen via een expliciete `workflow_dispatch` met de `deploy_production`-vlag aan. Een branch naar test deployen kan met een handmatige run (`deploy_test` en/of `deploy_asf_test`). Zie [`docs/deploy-en-testomgevingen.md`](docs/deploy-en-testomgevingen.md) voor invoer, testhosts, vereiste variabelen en secrets (alleen namen) en rollback. De pipeline publiceert framework-dependent voor `linux-arm64` en bouwt daarbij automatisch ook de admin-frontend mee naar `wwwroot/admin/`.
Elke deploy plaatst de nieuwe release in een verse map en wisselt pas daarna atomisch over naar `current` — er is dus nooit een moment waarop de applicatie een halfklare release serveert, en `wwwroot/web/` (de klantsite) staat structureel buiten die verwisselde map, zodat een deploy hem nooit kan raken. Volledige host-setup, rollback-procedure en de exacte deploy-stappen staan in de Operations-documentatie van deze feature, niet hier — dit README beschrijft alleen wat er gebouwd is, niet hoe je het voor het eerst inricht.
+14 -17
View File
@@ -17,7 +17,7 @@ De werkelijke health-URL's komen uit de Gitea-variabelen `HEALTH_CHECK_URL_TEST`
| Trigger | Wat er gebeurt |
|---|---|
| `pull_request` (opened, synchronize, reopened) | De poorten voor het master-CMS (`SlpModularCms.Api` met alle modules, Core, alle testprojecten via `SlpModularCms.Ci.slnf`; kwetsbaarheidscontrole; frontend build/test/lint) en de niet-verplichte `compile-sites` (alleen compileren van de dunne site-projecten). Er wordt **niet** gepubliceerd of gedeployed: een site wordt pas gebouwd bij een deploy. Een nieuwe push naar dezelfde PR annuleert de lopende run. |
| `push` op `master` | Dezelfde poorten, daarna automatisch `deploy-sls-test` (SlpSoftware test) en, als `ASF_TEST_DEPLOY_ENABLED` op `true` staat, ook `deploy-asf-test`. Nooit productie. |
| `push` op `master` | Dezelfde poorten, daarna automatisch `deploy-sls-test` (SlpSoftware test) en `deploy-asf-test` (ASF test). Nooit productie. |
| `workflow_dispatch` (handmatig, op elke gekozen branch) | Alle poorten draaien altijd volledig (het pad-filter meldt dan backend en frontend als gewijzigd). Deployen gebeurt alleen voor de aangevinkte invoer, zie hieronder. |
Poorten (jobs): `changes` (pad-filter), `backend-build`, `backend-test` (met een MariaDB-servicecontainer op poort 3308), `vulnerability-scan`, `frontend-prepare`, `frontend-build`, `frontend-test`, `frontend-lint`. Een poort die overgeslagen is (omdat die kant van de repo niet wijzigde) blokkeert niet; een poort die faalt of wordt geannuleerd blokkeert elke publish. Pad-filter bij push/PR: backend = `src/**`, `tests/**`, `*.sln`, `**/*.csproj` en de workflowbestanden; frontend = `frontend/**` en de workflowbestanden. Een run die geen van beide raakt publiceert niets.
@@ -28,7 +28,7 @@ Poorten (jobs): `changes` (pad-filter), `backend-build`, `backend-test` (met een
|---|---|---|
| `deploy_sls_test` | uit | Bouwt (`publish-sls-test`) en deployt naar SlpSoftware test |
| `deploy_sls_production` | uit | Bouwt (`publish-sls-production`) en deployt naar SlpSoftware productie, met databaseback-up vooraf |
| `deploy_asf_test` | uit | Bouwt (`publish-asf-test`) en deployt naar ASF test; alleen als ook `ASF_TEST_DEPLOY_ENABLED` op `true` staat |
| `deploy_asf_test` | uit | Bouwt (`publish-asf-test`) en deployt naar ASF test |
Zonder een van de drie aangevinkt draaien alleen de poorten (handig als losse CI-run). Meerdere tegelijk aanvinken kan. Let op: `deploy_sls_production` werkt alleen bij een run op een branch `release/*` (zelfde regel als ASF; de naam na `release/` is vrij, bijvoorbeeld `release/2026-11-20`). De condities van `publish-sls-production` en `deploy-sls-production` controleren de gebeurtenis (`workflow_dispatch`), de invoer en `startsWith(github.ref, 'refs/heads/release/')`; een run vanaf `master` of een featurebranch met `deploy_sls_production` aangevinkt doet voor productie niets. Een push deployt productie nooit.
@@ -57,8 +57,8 @@ Aandachtspunten:
## Wat `deploy` doet (per release)
1. Controleert dat `deploy_path`, `service_name` en `health_check_url` niet leeg zijn; anders stopt de deploy voordat de host wordt aangeraakt.
2. Zet SSH klaar: met de sleutel in `PI_MAIN_SSH_KEY` als die is ingesteld en werkt, anders met wachtwoord (`sshpass`).
1. Controleert dat `host` (`SLS_TEST`, `SLS_PROD` of `ASF_TEST`), `deploy_path`, `service_name` en `health_check_url` niet leeg zijn en dat de vier secrets van die host bestaan; anders stopt de deploy voordat de host wordt aangeraakt.
2. Zet SSH klaar met alleen de sleutel van die host (`<host>_HOST_SSH_KEY`, tijdelijk bestand met modus 600, `StrictHostKeyChecking=accept-new` met een known_hosts-bestand dat alleen voor deze job bestaat) en controleert de verbinding; er is geen wachtwoordaanmelding meer.
3. Alleen productie: `bash ~/scripts/backup-slpsoftware-db.sh <omgeving>` op de host (het script staat niet in deze repository).
4. Uploadt het artefact naar `<deploy_path>/releases/<UTC-tijdstempel>`.
5. Koppelt de blijvende websitemap `shared/wwwroot-web` als `wwwroot/web` in de release, en eventuele `shared/modules/*.dll`.
@@ -76,26 +76,23 @@ Aandachtspunten:
## Vereiste Gitea-secrets en -variabelen (alleen namen)
Secrets (SSH naar de host):
Secrets (SSH naar de host; per host dezelfde vier, met als voorvoegsel `SLS_TEST`, `SLS_PROD` of `ASF_TEST`; de drie hosts gebruiken nu één gedeelde deploy-sleutel):
| Naam | Gebruik |
|---|---|
| `PI_MAIN_ADDRESS`, `PI_MAIN_PORT`, `PI_MAIN_USERNAME` | Adres, poort en deploy-account |
| `PI_MAIN_PASSWORD` | Wachtwoord (terugval; werkt vanaf de runner die op de host mag inloggen met wachtwoord) |
| `PI_MAIN_SSH_KEY` | Optioneel: privésleutel van het deploy-account, nodig voor runners die niet met wachtwoord mogen |
| `<host>_HOST_ADDRESS`, `<host>_HOST_PORT`, `<host>_HOST_USERNAME` | Adres, poort en deploy-account |
| `<host>_HOST_SSH_KEY` | Privésleutel van het deploy-account (de publieke sleutel staat in `authorized_keys` van dat account) |
Variabelen:
Variabelen (`SLS_TEST`, `SLS_PROD`, `ASF_TEST`; voor ASF productie bestaan ze al maar er is nog geen ASF-productiejob):
| Naam | Voor |
|---|---|
| `DEPLOY_PATH_TEST`, `SERVICE_NAME_TEST`, `HEALTH_CHECK_URL_TEST` | SlpSoftware test. De `config-sls`-job faalt als een van deze drie leeg is (dat geldt voor elke run, ook een PR) |
| `DEPLOY_PATH_PRODUCTION`, `SERVICE_NAME_PRODUCTION`, `HEALTH_CHECK_URL_PRODUCTION` | SlpSoftware productie |
| `ASF_TEST_DEPLOY_ENABLED` | Schakelaar voor alle ASF-jobs; alleen de waarde `true` zet ze aan |
| `DEPLOY_PATH_ASF_TEST`, `SERVICE_NAME_ASF_TEST`, `HEALTH_CHECK_URL_ASF_TEST` | ASF test; `config-asf` faalt als er een leeg is (terwijl de schakelaar aan staat) |
| `VITE_SENTRY_DSN` | Sentry-DSN voor de SlpSoftware-adminbuild (test en productie) |
| `VITE_SENTRY_DSN_ASF` | Sentry-DSN voor de ASF-adminbuild |
| `VITE_UMAMI_SCRIPT_URL`, `VITE_UMAMI_WEBSITE_ID_TEST`, `VITE_UMAMI_WEBSITE_ID_PRODUCTION` | Umami voor de SlpSoftware-adminbuild (ASF gebruikt geen Umami) |
| `SECURITY_ALLOWED_SCRIPT_ORIGINS_TEST`, `SECURITY_ALLOWED_SCRIPT_ORIGINS_PRODUCTION` | Alleen gebruikt als controle in `publish-sls-test`/`publish-sls-production` wanneer `VITE_UMAMI_SCRIPT_URL` gevuld is: de Umami-origin moet in deze lijst staan, en de lijst moet overeenkomen met `SecurityHeaders__AllowedScriptOrigins__0` op de host |
| `<host>_DEPLOY_PATH`, `<host>_SERVICE_NAME`, `<host>_HEALTH_URL` | Release-map, systemd-service en `/health`-adres van die host. `config-sls` (SLS test) en `config-asf` falen als er een leeg is |
| `<host>_SENTRY_DSN` | Sentry-DSN voor de adminbuild van die site (wordt als `VITE_SENTRY_DSN` aan de build gegeven) |
| `SLS_TEST_UMAMI_SCRIPT_URL`, `SLS_TEST_UMAMI_WEBSITE_ID`, `SLS_PROD_UMAMI_SCRIPT_URL`, `SLS_PROD_UMAMI_WEBSITE_ID` | Umami voor de SlpSoftware-adminbuild (ASF gebruikt geen Umami) |
| `SLS_TEST_SECURITY_ALLOWED_SCRIPT_ORIGINS`, `SLS_PROD_SECURITY_ALLOWED_SCRIPT_ORIGINS` | Alleen gebruikt als controle in `publish-sls-test`/`publish-sls-production` wanneer de Umami-scripturl gevuld is: de Umami-origin moet in deze lijst staan, en de lijst moet overeenkomen met `SecurityHeaders__AllowedScriptOrigins__0` op de host |
De `VITE_*`-namen bestaan alleen nog als omgevingsvariabele binnen de buildstap, niet meer in Gitea.
Runtime-instellingen van de applicatie (verbindingsstring, JWT, mail, `Contact__*`, `Media__Directory`, Sentry) zitten niet in de workflow maar in het omgevingsbestand op de host (`shared/env`, zie README en de hostdocumentatie). Voor de afbeeldingen van de Hero-module hoort daar `Media__Directory` bij, een map buiten de release (`shared/media`), die de deploy niet aanraakt; zie [hero-module.md](hero-module.md).