Skip to content

Create test_deploy.yml #1

Create test_deploy.yml

Create test_deploy.yml #1

Workflow file for this run

name: Django Project Test and Deploy
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
Test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Docker-Compose
run: docker-compose up -d
- name: Run Tests
run: docker exec backend sh -c "flake8 && pytest ."
Deploy:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
name: Deploy
needs: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Connect and Execute Commands
uses: appleboy/ssh-action@master
with:
username: ${{secrets.USERNAME}}
password: ${{secrets.PASSWORD}}
host: ${{secrets.HOST}}
port: ${{secrets.PORT}}
script: |
cd ${{secrets.PROJECT_PATH}}
docker-compose -f docker-compose-stage.yml stop
git pull
docker-compose -f docker-compose-stage.yml restart