Skip to content

Commit

Permalink
ci: trigering deployment to ec2
Browse files Browse the repository at this point in the history
  • Loading branch information
yokwejuste committed Aug 8, 2024
1 parent 511ab9c commit b14400a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 48 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/push_to_ec2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy Django and Celery to EC2 instance

on:
push:
branches:
- dev

jobs:
deploy_project:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44.5.7
with:
since_last_remote_commit: true
separator: ","

- name: Copy files via scp using SSH key
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
port: ${{ secrets.PORT }}
source: "."
target: ${{ github.event.repository.name }}

build_project:
name: Build
needs: deploy_project
runs-on: ubuntu-latest
steps:
- name: Executing remote SSH commands using SSH key
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
port: ${{ secrets.PORT }}
script: |
cd aws-django-redis/
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart all
23 changes: 0 additions & 23 deletions Dockerfile

This file was deleted.

4 changes: 4 additions & 0 deletions celery_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

export $(cat ~/aws-django-redis/.env | xargs)
exec celery -A my_schedular worker --loglevel=INFO
7 changes: 2 additions & 5 deletions start.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash

/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord-web.conf &

/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord-celery.conf &

wait
export $(cat ~/aws-django-redis/.env | xargs)
exec gunicorn my_schedular.wsgi:application --bind 0.0.0.0:8000
10 changes: 0 additions & 10 deletions supervisord-celery.conf

This file was deleted.

10 changes: 0 additions & 10 deletions supervisord-web.conf

This file was deleted.

0 comments on commit b14400a

Please sign in to comment.