-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (45 loc) · 1.23 KB
/
main.yaml
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
40
41
42
43
44
45
46
47
48
49
50
name: Django CI/CD Workflow
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
package-job:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.x
deploy-job:
runs-on: ubuntu-latest
needs: [ package-job ]
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Deploy
if: ${{ job.status != 'failure' }}
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
key: ${{ secrets.SECRET_KEY_GITHUB }}
script: |
cd /var/www/oqtepalavash/backend
git add oqtepa.sqlite3 media/*
git commit -m "update database"
git push
git pull
source venv/bin/activate
pip install -r requirements.txt
systemctl restart backend.service
systemctl reload nginx.service
- name: Stop Workflow on Error
if: ${{ job.status == 'failure' }}
run: exit 1