CI deploy without sudo: tar over ssh when rsync missing
All checks were successful
Deploy to talkpro / build-and-sync (push) Successful in 33s
All checks were successful
Deploy to talkpro / build-and-sync (push) Successful in 33s
Remove apt/sudo install step (act runners lack sudo). Use rsync when available; otherwise clear remote web root and stream dist/ via tar|ssh. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build Astro dist/ and rsync to the Talk Pro marketing host (talkpro.info).
|
||||
# Build Astro dist/ and sync to the Talk Pro marketing host (talkpro.info).
|
||||
# Used by Gitea Actions and for manual deploys from this repo.
|
||||
#
|
||||
# Required (CI): TALKPRO_SSH_PRIVATE_KEY — PEM contents (Gitea secret)
|
||||
@@ -42,6 +42,7 @@ chmod 600 "$KEY_FILE"
|
||||
|
||||
SSH_OPTS=(-i "$KEY_FILE" -o BatchMode=yes -o StrictHostKeyChecking=accept-new)
|
||||
RSYNC_SSH="ssh -i \"$KEY_FILE\" -o BatchMode=yes -o StrictHostKeyChecking=accept-new"
|
||||
REMOTE="${USER}@${HOST}"
|
||||
|
||||
if [[ -f package-lock.json ]]; then
|
||||
npm ci
|
||||
@@ -51,13 +52,20 @@ fi
|
||||
npm run build
|
||||
|
||||
command -v ssh >/dev/null || { echo "ERROR: ssh not found (install openssh-client)" >&2; exit 127; }
|
||||
command -v rsync >/dev/null || { echo "ERROR: rsync not found (CI: apt-get install rsync)" >&2; exit 127; }
|
||||
|
||||
ssh "${SSH_OPTS[@]}" "${USER}@${HOST}" "mkdir -p ${REMOTE_ROOT}"
|
||||
ssh "${SSH_OPTS[@]}" "$REMOTE" "mkdir -p ${REMOTE_ROOT}"
|
||||
|
||||
rsync -avz --delete \
|
||||
-e "$RSYNC_SSH" \
|
||||
dist/ \
|
||||
"${USER}@${HOST}:${REMOTE_ROOT}/"
|
||||
if command -v rsync >/dev/null 2>&1; then
|
||||
echo "Uploading with rsync..."
|
||||
rsync -avz --delete \
|
||||
-e "$RSYNC_SSH" \
|
||||
dist/ \
|
||||
"${REMOTE}:${REMOTE_ROOT}/"
|
||||
else
|
||||
command -v tar >/dev/null || { echo "ERROR: need rsync or tar on the runner" >&2; exit 127; }
|
||||
echo "Uploading with tar over ssh (rsync not available on runner)..."
|
||||
ssh "${SSH_OPTS[@]}" "$REMOTE" "mkdir -p ${REMOTE_ROOT} && rm -rf ${REMOTE_ROOT:?}/*"
|
||||
tar -C dist -cf - . | ssh "${SSH_OPTS[@]}" "$REMOTE" "tar -C ${REMOTE_ROOT} -xf -"
|
||||
fi
|
||||
|
||||
echo "Deployed dist/ → ${USER}@${HOST}:${REMOTE_ROOT}/"
|
||||
echo "Deployed dist/ → ${REMOTE}:${REMOTE_ROOT}/"
|
||||
|
||||
Reference in New Issue
Block a user