-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (65 loc) · 2.96 KB
/
deploy-django.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Deploy Django Project
on:
push:
branches:
- Production-version # Trigger the workflow on push to the production branch
jobs:
deploy:
name: Deploy to Server
runs-on: production # This tells GitHub Actions to use the local runner
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.12' # Adjust the Python version according to your project
- name: Install Dependencies
run: |
mkdir -p ./INSIGHTSAPI/utils
python -m venv ./INSIGHTSAPI/utils/venv
source ./INSIGHTSAPI/utils/venv/bin/activate
pip install -r ./INSIGHTSAPI/requirements.txt
- name: Sync "excels" Directory
run: |
mkdir -p ./INSIGHTSAPI/utils/excels
rsync -av /var/www/INSIGHTS/INSIGHTSAPI/utils/excels/ ./INSIGHTSAPI/utils/excels/
- name: Sync "static" Directory
run: |
rsync -av /var/www/INSIGHTS/INSIGHTSAPI/static/ ./INSIGHTSAPI/static/
- name: Sync "secure/image" Directory
run: |
mkdir -p ./INSIGHTSAPI/secure/images
rsync -av /var/www/INSIGHTS/INSIGHTSAPI/secure/images/ ./INSIGHTSAPI/secure/images/
- name: Run Tests
run: |
source ./INSIGHTSAPI/utils/venv/bin/activate
cd INSIGHTSAPI
python manage.py test
- name: Run Migrations
run: |
source ./INSIGHTSAPI/utils/venv/bin/activate
python ./INSIGHTSAPI/manage.py migrate
- name: Deploy to production directory
run: |
sudo rsync -av --delete --exclude 'media/' --exclude 'logs/' --exclude='venv/' ./INSIGHTSAPI/ /var/www/INSIGHTS/INSIGHTSAPI/
- name: Recreate Virtual Environment
run: |
cd /var/www/INSIGHTS/INSIGHTSAPI/
if [ -d "utils/venv" ]; then
rm -rf utils/venv
fi
python3 -m venv utils/venv
- name: Install Dependencies
run: |
cd /var/www/INSIGHTS/INSIGHTSAPI/
source utils/venv/bin/activate
pip install -r /home/ares/actions-runner/_work/INSIGHTS/INSIGHTS/INSIGHTSAPI/requirements.txt
# Step 3: Install Python dependencies using the tested `requirements.txt`
- name: Grant Permissions to the Samba user to edit the files
run: |
chgrp -R www-data /var/www/INSIGHTS/INSIGHTSAPI/
chmod -R g+rwx /var/www/INSIGHTS/INSIGHTSAPI/
- name: Restart Nginx Service
run: |
sudo systemctl restart apache