Update deploy.yml
Some checks failed
Deploy / Deploy website via rsync over SSH (push) Has been cancelled

This commit is contained in:
2025-10-30 23:25:33 +01:00
parent ea702c6eed
commit d1f0f5a506

View File

@@ -1,4 +1,4 @@
name: Deploy Website
name: Deploy
on:
push:
@@ -7,60 +7,46 @@ on:
jobs:
deploy:
runs-on: self-hosted
name: Deploy website via rsync over SSH
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: 🧩 Checkout repository
uses: actions/checkout@v3
- name: Debug secrets presence
- name: 🧠 Check required secrets
run: |
echo "🧩 Checking secrets availability..."
for s in DEPLOY_KEY DEPLOY_HOST DEPLOY_USER DEPLOY_PATH DEPLOY_PORT; do
if [ -z "${!s}" ]; then
echo "❌ Secret $s is empty or undefined!"
for var in DEPLOY_KEY DEPLOY_USER DEPLOY_HOST DEPLOY_PORT DEPLOY_PATH; do
if [ -z "${!var}" ]; then
echo "❌ Secret $var is empty or undefined!" && exit 1
else
echo "✅ $s present (length: ${#s})"
echo "✅ $var present (length: ${#var})"
fi
done
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
shell: bash
- name: Set up SSH key (diagnostic)
- name: 🔐 Set up SSH key
run: |
set -euxo pipefail
echo "🏗️ Setting up SSH environment..."
mkdir -p ~/.ssh || (echo "❌ Could not create ~/.ssh" && exit 1)
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "📁 Listing home directory..."
ls -al ~
echo "🔑 Writing private key..."
printf "%s\n" "$DEPLOY_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "🔑 Writing private key to ~/.ssh/id_rsa"
echo "${DEPLOY_KEY}" | head -n 5 || echo "⚠️ DEPLOY_KEY variable empty or truncated"
printf "%s" "${DEPLOY_KEY}" > ~/.ssh/id_rsa || (echo "❌ Failed writing key file" && exit 1)
chmod 600 ~/.ssh/id_rsa
echo "📡 Adding ${DEPLOY_HOST}:${DEPLOY_PORT:-22} to known_hosts"
ssh-keyscan -p "${DEPLOY_PORT:-22}" -H "${DEPLOY_HOST}" >> ~/.ssh/known_hosts 2>/dev/null || echo "⚠️ ssh-keyscan warning (ignored)"
echo "📡 Adding ${DEPLOY_HOST}:${DEPLOY_PORT} to known_hosts..."
ssh-keyscan -p "$DEPLOY_PORT" -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
echo "✅ SSH setup complete!"
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
shell: bash
- name: Deploy website via rsync
- name: 🚀 Deploy via rsync
run: |
echo "🚀 Deploying site..."
rsync -avz -e "ssh -p ${DEPLOY_PORT:-22}" --delete ./ \
${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}
echo "✅ Deployment complete!"
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
echo "🚀 Starting rsync deployment..."
rsync -avz \
--delete \
-e "ssh -i ~/.ssh/id_ed25519 -p $DEPLOY_PORT -o StrictHostKeyChecking=no" \
./ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
echo "✅ Deployment finished successfully!"
shell: bash