#!/usr/bin/env bash # usage: ssh-run.sh # Runs one deploy-lib.sh stage on the workstation over SSH. set -euo pipefail : "${DEPLOY_HOST:?missing DEPLOY_HOST}" : "${DEPLOY_USER:?missing DEPLOY_USER}" : "${DEPLOY_KEY:?missing DEPLOY_SSH_KEY}" deploy_port="${DEPLOY_PORT:-22}" deploy_path="${DEPLOY_PATH:-/srv/homelab}" deploy_path="$(printf '%s' "$deploy_path" | tr -d '\"' | tr -d '\r' | xargs)" ssh_key="$RUNNER_TEMP/deploy_key" mkdir -p "$RUNNER_TEMP" printf '%s\n' "$DEPLOY_KEY" > "$ssh_key" chmod 600 "$ssh_key" ssh -i "$ssh_key" -p "$deploy_port" \ -o BatchMode=yes -o StrictHostKeyChecking=accept-new \ "${DEPLOY_USER}@${DEPLOY_HOST}" \ "REPO=$deploy_path APPLY_PRUNE=${APPLY_PRUNE:-false} STAGE=$1 bash -se" <<'EOF' source "$REPO/.gitea/workflows/deploy-lib.sh" run_stage "$STAGE" EOF