sitemaps confiurations #37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to EC2 | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Add SSH key | |
| uses: webfactory/ssh-agent@v0.8.0 | |
| with: | |
| ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| - name: Deploy to EC2 | |
| run: | | |
| ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF' | |
| set -e | |
| cd ~/github_management/RB | |
| echo "Pulling latest code..." | |
| git fetch origin main | |
| git reset --hard origin/main | |
| echo "Activating virtual environment..." | |
| source venv/bin/activate | |
| echo "Installing dependencies..." | |
| pip install -r requirements.txt | |
| echo "Running migrations..." | |
| python manage.py migrate --noinput | |
| echo "Restarting celery..." | |
| sudo systemctl restart celery | |
| echo "Restarting Gunicorn..." | |
| sudo systemctl restart gunicorn | |
| echo "✅ Deployment successful!" | |
| EOF |