-
Notifications
You must be signed in to change notification settings - Fork 1
35 lines (30 loc) · 1.18 KB
/
deploy.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
---
name: Deploy Django Application
on:
push:
branches:
- production
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install rsync and configure SSH
run: |
sudo apt-get install -y rsync
echo "${{ secrets.DEPLOY_SERVER_SSH_KEY }}" > private_key.pem
chmod 600 private_key.pem
- name: Deploy to remote server
env:
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
REMOTE_DIR: ${{ secrets.DEPLOY_PATH }}
run: |
rsync -avz --itemize-changes --omit-dir-times --no-perms --delete --exclude '.git' --exclude 'private_key.pem' --exclude '**/__pycache__' -e "ssh -i private_key.pem -o StrictHostKeyChecking=no" ./ ${{ env.REMOTE_USER }}@${{ env.REMOTE_HOST }}:${{ env.REMOTE_DIR }}
ssh -i private_key.pem -o StrictHostKeyChecking=no ${{ env.REMOTE_USER }}@${{ env.REMOTE_HOST }} "\
sudo /usr/bin/pkill gunicorn || true && cd ${{ secrets.DEPLOY_PATH }}/scripts && /bin/bash 07_run.sh"