Files
SlpSoftware/.gitea/workflows/deploy.yaml
SluijsensandClaude Sonnet 5.5 4577875575
Continuous Integration / config (pull_request) Successful in 6s
Continuous Integration / prepare (pull_request) Successful in 29s
Continuous Integration / build-production (pull_request) Skipped
Continuous Integration / test (pull_request) Successful in 36s
Continuous Integration / build (pull_request) Successful in 44s
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / lighthouse (pull_request) Successful in 2m16s
Continuous Integration / deploy-production (pull_request) Skipped
Pipeline: nieuwe Gitea-namen en deploy met SSH-sleutel (geen wachtwoord meer)
TEST_/PROD_-variabelen (DEPLOY_PATH, UMAMI, SENTRY) en TEST_HOST_*/PROD_HOST_* secrets.
Wachtwoord-terugval (sshpass) verwijderd; StrictHostKeyChecking=accept-new.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-18 20:21:39 +01:00

67 lines
3.1 KiB
YAML

name: Deploy
on:
workflow_call:
inputs:
artifact_name:
required: true
type: string
environment:
required: true
type: string
deploy_path:
required: true
type: string
jobs:
deploy:
# 'linux' = elke vrije runner. Geen runner-specifieke aannames in deze job (zie de
# installatiestap hieronder); valt dit ooit om, zet het dan terug op 'raspberry-pi'.
runs-on: linux
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact_name }}
path: ${{ inputs.artifact_name }}
# Uploadt de inhoud van dist/ via SCP (over SSH) naar de webroot van de
# omgeving (een Raspberry Pi achter een andere Raspberry Pi met nginx
# reverse proxy - zie operations/deployment/nginx/). Inloggen gaat met
# een SSH-sleutel; de secrets heten per omgeving TEST_HOST_* en PROD_HOST_*
# (naamgeving: aidlc-docs/_shared/gitea-naamgeving-variabelen.md).
#
# Let op: dit gebeurt via een gewone shell-stap in plaats van de
# appleboy/scp-action Docker-container-action. Die laatste faalt op
# deze runner met "failed to attach to container: unable to upgrade
# to tcp, received 409" (Podman). Een scp-commando in een normale run-stap
# heeft die geneste container niet nodig.
- name: Upload dist to ${{ inputs.environment }} web server via SCP
env:
# Secrets via env: in plaats van in het script te interpoleren, zodat
# shell-metatekens in een waarde niet alsnog worden uitgevoerd.
HOST_SSH_KEY: ${{ inputs.environment == 'production' && secrets.PROD_HOST_SSH_KEY || secrets.TEST_HOST_SSH_KEY }}
HOST_PORT: ${{ inputs.environment == 'production' && secrets.PROD_HOST_PORT || secrets.TEST_HOST_PORT }}
HOST_USERNAME: ${{ inputs.environment == 'production' && secrets.PROD_HOST_USERNAME || secrets.TEST_HOST_USERNAME }}
HOST_ADDRESS: ${{ inputs.environment == 'production' && secrets.PROD_HOST_ADDRESS || secrets.TEST_HOST_ADDRESS }}
run: |
# Runner-onafhankelijk: werkt op elke Linux-runner met scp. De tool wordt alleen
# geinstalleerd als hij ontbreekt. Er is geen wachtwoord-terugval meer.
SUDO=""
if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then SUDO="sudo"; fi
if ! command -v scp >/dev/null 2>&1; then
$SUDO apt-get update && $SUDO apt-get install -y openssh-client
fi
if [ -z "$HOST_SSH_KEY" ]; then
echo "SSH-sleutel ontbreekt (secret ${{ inputs.environment == 'production' && 'PROD_HOST_SSH_KEY' || 'TEST_HOST_SSH_KEY' }})"; exit 1
fi
KEYFILE="$(mktemp)"
trap 'rm -f "$KEYFILE"' EXIT
printf '%s\n' "$HOST_SSH_KEY" > "$KEYFILE"
chmod 600 "$KEYFILE"
scp \
-P "$HOST_PORT" \
-i "$KEYFILE" -o IdentitiesOnly=yes -o BatchMode=yes \
-o StrictHostKeyChecking=accept-new \
-r ${{ inputs.artifact_name }}/* \
"$HOST_USERNAME@$HOST_ADDRESS:${{ inputs.deploy_path }}"