Refactor SSH setup in deployment workflow to enhance secrets presence checks and improve output clarity
Some checks failed
Deploy Development / deploy (push) Failing after 1m17s

This commit is contained in:
Frank John Begornia
2025-12-16 14:16:30 +08:00
parent aaa043f06e
commit 8e8bfd1897

View File

@@ -28,27 +28,39 @@ jobs:
docker build -t merchbay_admin:dev .
docker save merchbay_admin:dev | gzip > merchbay_admin_dev.tar.gz
- name: Setup SSH
- name: Debug secrets (safe)
shell: sh
run: |
set -e
echo "== Secrets presence check =="
if [ -z "${DEPLOY_SSH_KEY}" ]; then
echo "❌ DEPLOY_SSH_KEY is EMPTY"
exit 1
echo "❌ DEPLOY_SSH_KEY is EMPTY or NOT SET"
else
echo "✅ DEPLOY_SSH_KEY is SET"
echo "Length: ${#DEPLOY_SSH_KEY}"
echo "First line:"
echo "${DEPLOY_SSH_KEY}" | head -n 1
echo "Last line:"
echo "${DEPLOY_SSH_KEY}" | tail -n 1
fi
mkdir -p ~/.ssh
chmod 700 ~/.ssh
if [ -z "${DEPLOY_USER}" ]; then
echo "❌ DEPLOY_USER is EMPTY"
else
echo "✅ DEPLOY_USER = ${DEPLOY_USER}"
fi
echo "${DEPLOY_SSH_KEY}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${DEPLOY_HOST} >> ~/.ssh/known_hosts
if [ -z "${DEPLOY_HOST}" ]; then
echo "❌ DEPLOY_HOST is EMPTY"
else
echo "✅ DEPLOY_HOST = ${DEPLOY_HOST}"
fi
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
- name: Deploy to Server
shell: sh
run: |