diff --git a/.gitea/workflows/continuous_integration.yaml b/.gitea/workflows/continuous_integration.yaml index 47c7a82..53e298a 100644 --- a/.gitea/workflows/continuous_integration.yaml +++ b/.gitea/workflows/continuous_integration.yaml @@ -212,18 +212,26 @@ jobs: - name: Upload naar de testserver env: # Secrets via env, zodat bash tekens als $ of ` niet nog eens uitlegt - SSHPASS: ${{ secrets.PI_MAIN_PASSWORD }} - SSH_PORT: ${{ secrets.PI_MAIN_PORT }} - SSH_USER: ${{ secrets.PI_MAIN_USERNAME }} - SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }} + SSH_KEY: ${{ secrets.TEST_HOST_SSH_KEY }} + SSH_PORT: ${{ secrets.TEST_HOST_PORT }} + SSH_USER: ${{ secrets.TEST_HOST_USERNAME }} + SSH_HOST: ${{ secrets.TEST_HOST_ADDRESS }} DEPLOY_PATH: ${{ vars.TEST_DEPLOY_PATH }} run: | case "$DEPLOY_PATH" in ''|'/'|*' '*) echo "TEST_DEPLOY_PATH ontbreekt of is ongeldig: '$DEPLOY_PATH'"; exit 1 ;; esac - sudo apt-get update && sudo apt-get install -y sshpass - SSH="sshpass -e ssh -p $SSH_PORT -o StrictHostKeyChecking=accept-new $SSH_USER@$SSH_HOST" - $SSH "set -e + for name in SSH_KEY SSH_PORT SSH_USER SSH_HOST; do + [ -n "${!name}" ] || { echo "Secret TEST_HOST_${name#SSH_} ontbreekt"; exit 1; } + done + # Inloggen met de deploysleutel, geen wachtwoord. De sleutel gaat naar + # een tijdelijk bestand dat na afloop verdwijnt. + KEY_FILE="$(mktemp)" + trap 'rm -f "$KEY_FILE"' EXIT + printf '%s\n' "$SSH_KEY" > "$KEY_FILE" + chmod 600 "$KEY_FILE" + SSH_OPTS=(-i "$KEY_FILE" -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new) + ssh -p "$SSH_PORT" "${SSH_OPTS[@]}" "$SSH_USER@$SSH_HOST" "set -e if [ -e '$DEPLOY_PATH/wp-config.php' ] || [ -d '$DEPLOY_PATH/wp-content' ]; then echo 'Geweigerd: $DEPLOY_PATH bevat WordPress'; exit 1 fi @@ -234,7 +242,7 @@ jobs: # mag. Zo zijn groeps-schrijfrechten op de doelmap genoeg. # dotglob: ook bestanden die met een punt beginnen gaan mee. shopt -s dotglob - sshpass -e scp -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new -r dist/* "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/" + scp -P "$SSH_PORT" "${SSH_OPTS[@]}" -r dist/* "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/" echo "Gedeployd naar test: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})" # Vergelijkt wat de server teruggeeft met dist. Met de oude nginx-config diff --git a/docs/deploy-and-ci.md b/docs/deploy-and-ci.md index 4eba814..504125c 100644 --- a/docs/deploy-and-ci.md +++ b/docs/deploy-and-ci.md @@ -58,17 +58,17 @@ The production site gets the same only when the ASF production site is served by Format `{ENV}_{GROUP}_{NAME}` with `ENV` = `TEST` or `PROD`, no app part (this repo only deploys the ASF site) and no `VITE` (the pipeline maps a value to `VITE_...` in the build). Decision of Bryan, 2026-11-18; the full list is in the SLS repo (`aidlc-docs/_shared/gitea-naamgeving-variabelen.md`). Repo variables and secrets are created by SLS, not by feature sessions. -| Name | Kind | Used by | -| ------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | -| `TEST_DEPLOY_PATH` | variable | `deploy-test`: target folder on the Pi | -| `TEST_HEALTH_URL` | variable | `deploy-test`: check after the deploy | -| `PROD_DEPLOY_PATH` | variable | `deploy-production`: remote folder (default `wwwroot`) | -| `PROD_HEALTH_URL` | variable | `deploy-production`: check after the deploy | -| `TEST_SENTRY_DSN`, `TEST_UMAMI_SCRIPT_URL`, `TEST_UMAMI_WEBSITE_ID` | variable | `build-test` and the CSP check in `deploy-test` (as `VITE_SENTRY_DSN`, `VITE_UMAMI_SCRIPT_URL`, `VITE_UMAMI_WEBSITE_ID`, `VITE_APP_ENV=test`) | -| `PROD_SENTRY_DSN`, `PROD_UMAMI_SCRIPT_URL`, `PROD_UMAMI_WEBSITE_ID` | variable | `check` (the production artifact; `VITE_APP_ENV=production`) | -| `PROD_HOST_ADDRESS`, `PROD_HOST_USERNAME`, `PROD_HOST_PASSWORD` | secrets | `deploy-production`: FTP (plain FTP, no FTPS, at the hosting partner) | -| `PI_MAIN_ADDRESS`, `_PORT`, `_USERNAME`, `_PASSWORD` | secrets | `deploy-test`: still the old names; they become `TEST_HOST_*` with an SSH key (SLS arranges the key) | +| Name | Kind | Used by | +| -------------------------------------------------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- | +| `TEST_DEPLOY_PATH` | variable | `deploy-test`: target folder on the Pi | +| `TEST_HEALTH_URL` | variable | `deploy-test`: check after the deploy | +| `PROD_DEPLOY_PATH` | variable | `deploy-production`: remote folder (default `wwwroot`) | +| `PROD_HEALTH_URL` | variable | `deploy-production`: check after the deploy | +| `TEST_SENTRY_DSN`, `TEST_UMAMI_SCRIPT_URL`, `TEST_UMAMI_WEBSITE_ID` | variable | `build-test` and the CSP check in `deploy-test` (as `VITE_SENTRY_DSN`, `VITE_UMAMI_SCRIPT_URL`, `VITE_UMAMI_WEBSITE_ID`, `VITE_APP_ENV=test`) | +| `PROD_SENTRY_DSN`, `PROD_UMAMI_SCRIPT_URL`, `PROD_UMAMI_WEBSITE_ID` | variable | `check` (the production artifact; `VITE_APP_ENV=production`) | +| `PROD_HOST_ADDRESS`, `PROD_HOST_USERNAME`, `PROD_HOST_PASSWORD` | secrets | `deploy-production`: FTP (plain FTP, no FTPS, at the hosting partner) | +| `TEST_HOST_ADDRESS`, `TEST_HOST_PORT`, `TEST_HOST_USERNAME`, `TEST_HOST_SSH_KEY` | secrets | `deploy-test`: SSH key login to the Pi (one shared deploy key; no password) | -Removed: `DEPLOY_PATH_TEST`, `HEALTH_CHECK_URL_TEST`, `HEALTH_CHECK_URL_PRODUCTION`, `FTP_REMOTE_DIR`, `FTP_HOST`, `FTP_USERNAME`, `FTP_PASSWORD` (renamed), `ASF_OFFERINGS_URL_TEST` and `ASF_TEST_SERVED_BY_CMS` (no longer needed). The old names in the repo are removed by SLS after a green run. +Removed: `PI_MAIN_*` (the SSH password login; the old secrets are deleted by Bryan after a green run), `DEPLOY_PATH_TEST`, `HEALTH_CHECK_URL_TEST`, `HEALTH_CHECK_URL_PRODUCTION`, `FTP_REMOTE_DIR`, `FTP_HOST`, `FTP_USERNAME`, `FTP_PASSWORD` (renamed), `ASF_OFFERINGS_URL_TEST` and `ASF_TEST_SERVED_BY_CMS` (no longer needed). The old names in the repo are removed by SLS after a green run. **Monitoring per build.** Sentry and Umami settings are no longer in the code (`src/monitoring/config.ts`): every build gets them for its own environment and measures only on that environment's host (production build on `andreaslop.nl`, test build on `test.andreaslop.nl`; any other host measures nothing). The CSP origins for Umami and Sentry (`config/securityHeaders.ts`) come from the same variables, so a build without them has neither a measurement nor those origins; the build steps fail when a variable is empty. Unit and browser tests use the production values from `config/monitoringTestEnv.ts` (public values, the same as the variables); `pnpm server-config` does too, so the committed generated files carry the production CSP. The CMS host has its own copy of the origins in its environment (CMS repo).