Skip to content

Commit

Permalink
Merge pull request #56 from bendsouza2/enhancement/backend-deploy
Browse files Browse the repository at this point in the history
ensure gunicorn restart when backend updates pushed
  • Loading branch information
bendsouza2 authored Jan 11, 2025
2 parents ee105f0 + b8bbb19 commit 49017cb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .github/workflows/deploy_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to EC2

on:
push:
branches:
- main
paths:
- app/**

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/yt_translator
app/post_update.sh
10 changes: 9 additions & 1 deletion app/post_update.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/bash

cd ~/yt_translator
git pull origin main

# Copy custom settings file
if [ ! -f settings.py ]; then
if [ ! -f video_host/settings.py ]; then
echo "Restoring settings.py..."
cp /home/ubuntu/settings_backup/settings.py video_host/settings.py
fi

source /home/ubuntu/yt_translator/venv/bin/activate
python manage.py migrate

sudo systemctl stop gunicorn
sudo systemctl daemon-reload
sudo systemctl start gunicorn
sudo systemctl enable gunicorn


0 comments on commit 49017cb

Please # to comment.