uchill/.gitea/workflows/deploy-dev.yml

63 lines
2.1 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy to Dev
on:
push:
branches: [ main, master, develop, dev ]
jobs:
deploy-dev:
runs-on: ubuntu-latest
steps:
- name: Setup SSH Key
run: |
mkdir -p /tmp/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > /tmp/.ssh/deploy_key
chmod 600 /tmp/.ssh/deploy_key
echo "SSH key file created at /tmp/.ssh/deploy_key"
head -1 /tmp/.ssh/deploy_key
tail -1 /tmp/.ssh/deploy_key
wc -l /tmp/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.DEV_HOST }} >> /tmp/.ssh/known_hosts 2>/dev/null || true
- name: Deploy to Dev Server
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USER }}
key_path: /tmp/.ssh/deploy_key
use_insecure_cipher: true
debug: true
script: |
set -e
cd /var/www/platform/dev
echo "📦 Pulling latest changes from repository..."
git pull origin main || git pull origin master || git pull origin develop || git pull origin dev || true
echo "🔄 Restarting Docker services..."
docker compose restart
echo "📊 Running migrations (if needed)..."
docker compose exec -T web python manage.py migrate || true
echo "📁 Collecting static files (if needed)..."
docker compose exec -T web python manage.py collectstatic --noinput || true
echo "✅ Dev deployment completed successfully"
echo " You can continue working directly on the server"
- name: Health Check
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_USER }}
key_path: /tmp/.ssh/deploy_key
use_insecure_cipher: true
debug: true
script: |
sleep 10
docker compose ps
curl -f http://localhost:8124/health/ || exit 1
echo "✅ Health check passed"