-
Notifications
You must be signed in to change notification settings - Fork 11
34 lines (34 loc) · 1.32 KB
/
deploy_production.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
name: Production deploy
on:
push:
tags:
- v**
jobs:
deploy:
name: Deploy to production server
runs-on: [self-hosted, sport]
environment:
name: production
url: https://sport.innopolis.university
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd ${{ secrets.REPOSITORY_PATH }}/deploy
git reset --hard
git fetch
git checkout ${{ github.ref_name }}
git pull
python3 ${{ secrets.BACKUP_SCRIPT }}
docker compose -f docker-compose.prod.yaml pull
docker compose -f docker-compose.prod.yaml build --pull
docker compose -f docker-compose.prod.yaml down
docker compose -f docker-compose.prod.yaml up -d
docker compose -f docker-compose.prod.yaml exec -T adminpanel bash -c "while !</dev/tcp/db/5432; do sleep 1; done;"
docker compose -f docker-compose.prod.yaml exec -T adminpanel bash -c 'python3 manage.py collectstatic --noinput && python3 manage.py migrate && python3 manage.py createcachetable'
python3 ${{ secrets.BACKUP_SCRIPT }}