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