deploy-test: SSH key login (TEST_HOST_*) instead of the PI_MAIN_* password with sshpass
Continuous Integration / check (pull_request) Successful in 2m24s
Continuous Integration / build-test (pull_request) Skipped
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 11m38s
Continuous Integration / deploy-production (pull_request) Skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 20:20:31 +01:00
co-authored by Claude Sonnet 5.5
parent d99b909f9f
commit 2147fcec35
2 changed files with 27 additions and 19 deletions
+16 -8
View File
@@ -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