Skip to content

.github/workflows/deploy.yml #36

.github/workflows/deploy.yml

.github/workflows/deploy.yml #36

Workflow file for this run

name: Deploy project
on:
workflow_run:
workflows: [Django CI]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install SSH key
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to server
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.IP_ADDRESS }} "cd ~/Virtual-Bank && git pull origin main" || exit 1
- name: Collect API static
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.IP_ADDRESS }} "cd ~/Virtual-Bank/api && python3 manage.py collectstatic --noinput" || exit 1
- name: Collect clients static
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.IP_ADDRESS }} "cd ~/Virtual-Bank/clients && python3 manage.py collectstatic --noinput" || exit 1
- name: Restart and reload
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.IP_ADDRESS }} "sudo service nginx restart && pkill -HUP -f gunicorn" || exit 1