Skip to content

Staging deploy

Staging deploy #13

name: Staging deploy
on:
workflow_dispatch:
workflow_run:
workflows: ["Tests"]
branches: [main]
types:
- completed
jobs:
deploy:
name: Deploy to staging server
runs-on: [self-hosted, sport]
environment:
name: development
url: https://stage.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
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 './manage.py collectstatic --noinput && ./manage.py migrate && ./manage.py createcachetable'
docker compose -f docker-compose.prod.yaml build nginx
docker compose -f docker-compose.prod.yaml restart nginx