Dalgo CD #18
This file contains 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: Dalgo CD | |
on: | |
push: | |
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 | |