KAN-63: activate heztner depoy steps

This commit is contained in:
Gabos Levente 2025-06-27 16:22:11 +03:00
parent 37b327c957
commit fe66f7d2ee

View file

@ -12,7 +12,7 @@ on:
environment: environment:
description: 'Deployment environment' description: 'Deployment environment'
required: false required: false
default: 'production' default: 'test'
type: choice type: choice
options: options:
- production - production
@ -34,7 +34,7 @@ on:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
HETZNER_HOST: 188.245.211.114 HETZNER_HOST: 188.245.211.114
HETZNER_USER: frappe HETZNER_USER: ignis_academy_lms
DEPLOY_PATH: /opt/frappe-deployment DEPLOY_PATH: /opt/frappe-deployment
jobs: jobs:
@ -111,82 +111,82 @@ jobs:
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
# - name: Setup SSH key - name: Setup SSH key
# uses: webfactory/ssh-agent@v0.8.0 uses: webfactory/ssh-agent@v0.8.0
# with: with:
# ssh-private-key: ${{ secrets.HETZNER_SSH_KEY }} ssh-private-key: ${{ secrets.HETZNER_SSH_KEY }}
# - name: Add Hetzner server to known hosts - name: Add Hetzner server to known hosts
# run: | run: |
# ssh-keyscan -H ${{ env.HETZNER_HOST }} >> ~/.ssh/known_hosts ssh-keyscan -H ${{ env.HETZNER_HOST }} >> ~/.ssh/known_hosts
# - name: Deploy to Hetzner - name: Deploy to Hetzner
# run: | run: |
# # Copy deployment files to server # Copy deployment files to server
# scp -r compose.yaml nginx/ scripts/ ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }}:${{ env.DEPLOY_PATH }}/ scp -r compose.yaml nginx/ scripts/ ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }}:${{ env.DEPLOY_PATH }}/
# # Copy environment file if it doesn't exist # Copy environment file if it doesn't exist
# ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} " ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} "
# cd ${{ env.DEPLOY_PATH }} cd ${{ env.DEPLOY_PATH }}
# if [ ! -f .env ]; then if [ ! -f .env ]; then
# cp .env.example .env cp .env.example .env
# echo 'Please update .env file with your configuration' echo 'Please update .env file with your configuration'
# fi fi
# " "
# # Login to private registry # Login to private registry
# ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} " ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} "
# echo '${{ secrets.GITHUB_TOKEN }}' | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin echo '${{ secrets.GITHUB_TOKEN }}' | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
# " "
# - name: Update and restart services - name: Update and restart services
# run: | run: |
# ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} " ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} "
# cd ${{ env.DEPLOY_PATH }} cd ${{ env.DEPLOY_PATH }}
# # Pull latest images # Pull latest images
# docker compose pull docker compose pull
# # Stop services gracefully # Stop services gracefully
# docker compose down --timeout 30 docker compose down --timeout 30
# # Start services # Start services
# docker compose up -d docker compose up -d
# # Wait for services to be ready # Wait for services to be ready
# sleep 30 sleep 30
# # Run migrations on all sites # Run migrations on all sites
# ./scripts/migrate-all-sites.sh ./scripts/migrate-all-sites.sh
# # Show status # Show status
# docker compose ps docker compose ps
# " "
# - name: Health check - name: Health check
# run: | run: |
# # Wait a bit more for services to fully start # Wait a bit more for services to fully start
# sleep 60 sleep 60
# # Check if nginx-proxy is responding # Check if nginx-proxy is responding
# if curl -f http://${{ env.HETZNER_HOST }}/health; then if curl -f http://${{ env.HETZNER_HOST }}/health; then
# echo "✅ Deployment successful - Health check passed" echo "✅ Deployment successful - Health check passed"
# else else
# echo "❌ Health check failed" echo "❌ Health check failed"
# # Show logs for debugging # Show logs for debugging
# ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} " ssh ${{ env.HETZNER_USER }}@${{ env.HETZNER_HOST }} "
# cd ${{ env.DEPLOY_PATH }} cd ${{ env.DEPLOY_PATH }}
# docker compose logs --tail=50 docker compose logs --tail=50
# " "
# exit 1 exit 1
# fi fi
# - name: Notify deployment status - name: Notify deployment status
# if: always() if: always()
# run: | run: |
# if [ "${{ job.status }}" == "success" ]; then if [ "${{ job.status }}" == "success" ]; then
# echo "🚀 Deployment to Hetzner completed successfully!" echo "🚀 Deployment to Hetzner completed successfully!"
# echo "🌐 Access your application at: http://${{ env.HETZNER_HOST }}" echo "🌐 Access your application at: http://${{ env.HETZNER_HOST }}"
# else else
# echo "💥 Deployment failed. Check the logs above for details." echo "💥 Deployment failed. Check the logs above for details."
# fi fi