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