If this not work I give up for today
Some checks failed
Deploy Website / deploy (push) Failing after 3s

This commit is contained in:
2025-10-30 22:18:12 +00:00
parent 2534cbcdf5
commit ea702c6eed

View File

@@ -3,33 +3,26 @@ name: Deploy Website
on: on:
push: push:
branches: branches:
- rewrite-static # ✅ your current branch - rewrite-static
jobs: jobs:
deploy: deploy:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
# --- 1. Checkout repository ---
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v3
# --- 2. Debug environment --- - name: Debug secrets presence
- name: Debug secrets and environment
run: | run: |
echo "🧩 Debugging environment" echo "🧩 Checking secrets availability..."
echo "Branch: ${{ gitea.ref }}" for s in DEPLOY_KEY DEPLOY_HOST DEPLOY_USER DEPLOY_PATH DEPLOY_PORT; do
echo "Host: ${DEPLOY_HOST}" if [ -z "${!s}" ]; then
echo "User: ${DEPLOY_USER}" echo "❌ Secret $s is empty or undefined!"
echo "Path: ${DEPLOY_PATH}" else
echo "Port: ${DEPLOY_PORT:-22}" echo "✅ $s present (length: ${#s})"
fi
if [ -n "${DEPLOY_KEY}" ]; then done
echo "✅ DEPLOY_KEY is set (length: ${#DEPLOY_KEY})"
else
echo "❌ DEPLOY_KEY is missing!"
exit 1
fi
env: env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
@@ -37,44 +30,35 @@ jobs:
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
# --- 3. Set up SSH key --- - name: Set up SSH key (diagnostic)
- name: Set up SSH key
run: | run: |
set -euxo pipefail set -euxo pipefail
echo "🏗️ Setting up SSH environment..."
echo "🔑 Preparing SSH" mkdir -p ~/.ssh || (echo "❌ Could not create ~/.ssh" && exit 1)
mkdir -p ~/.ssh
chmod 700 ~/.ssh chmod 700 ~/.ssh
echo "🔍 Checking private key variable" echo "📁 Listing home directory..."
if [ -z "${DEPLOY_KEY}" ]; then ls -al ~
echo "❌ DEPLOY_KEY is empty"
exit 1
fi
echo "📝 Writing SSH private key to ~/.ssh/id_rsa" echo "🔑 Writing private key to ~/.ssh/id_rsa"
printf "%s" "${DEPLOY_KEY}" > ~/.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 chmod 600 ~/.ssh/id_rsa
echo "📡 Scanning SSH host key for ${DEPLOY_HOST}:${DEPLOY_PORT:-22}" echo "📡 Adding ${DEPLOY_HOST}:${DEPLOY_PORT:-22} to known_hosts"
if ! ssh-keyscan -p "${DEPLOY_PORT:-22}" -H "${DEPLOY_HOST}" >> ~/.ssh/known_hosts 2>/dev/null; then ssh-keyscan -p "${DEPLOY_PORT:-22}" -H "${DEPLOY_HOST}" >> ~/.ssh/known_hosts 2>/dev/null || echo "⚠️ ssh-keyscan warning (ignored)"
echo "⚠️ Warning: ssh-keyscan failed (host may be unreachable temporarily)" echo "✅ SSH setup complete!"
fi
echo "✅ SSH key and known_hosts setup complete"
env: env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
# --- 4. Deploy website via rsync ---
- name: Deploy website via rsync - name: Deploy website via rsync
run: | run: |
echo "🚀 Starting deployment to ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH} (port ${DEPLOY_PORT:-22})" echo "🚀 Deploying site..."
rsync -avz -e "ssh -p ${DEPLOY_PORT:-22}" --delete ./ \ rsync -avz -e "ssh -p ${DEPLOY_PORT:-22}" --delete ./ \
${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH} ${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}
echo "✅ Deployment complete!"
echo "✅ Deployment completed successfully!"
env: env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }}