-
Notifications
You must be signed in to change notification settings - Fork 42
39 lines (35 loc) · 1.1 KB
/
dalgo-cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Dalgo CD
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_run:
workflows: ["Dalgo CI"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy code to EC2 server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVERIP }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
command_timeout: 500s
script: |
set -e
source ~/.nvm/nvm.sh
cd /home/ddp/DDP_backend
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [ "$current_branch" != "main" ]; then
echo "Error: You are not on the main branch. Current branch is $current_branch."
exit 1
fi
git pull
/home/ddp/DDP_backend/venv/bin/python manage.py migrate
/home/ddp/DDP_backend/venv/bin/python manage.py loaddata seed/*.json
/home/ddp/.yarn/bin/pm2 restart django-celery-worker django-backend-asgi