diff --git a/.github/workflows/deploy_backend.yml b/.github/workflows/deploy_backend.yml new file mode 100644 index 0000000..8eb8378 --- /dev/null +++ b/.github/workflows/deploy_backend.yml @@ -0,0 +1,33 @@ +name: Deploy to Server + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + environment: deployTest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.POLYHISTOR_PRIVATE_KEY }} + + - name: Deploy to server + env: + SSH_HOST: ${{ secrets.POLYHISTOR_SSH_HOST }} + SSH_USER: ${{ secrets.POLYHISTOR_SSH_USER }} + SSH_PORT: ${{ secrets.POLYHISTOR_SSH_PORT }} + run: | + ssh -o StrictHostKeyChecking=no -p $SSH_PORT $SSH_USER@$SSH_HOST << 'EOF' + cd polyhistor + git pull origin main + chmod +x deploy.sh + ./deploy.sh + + EOF diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..1fae6d7 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,3 @@ +sudo docker stop polyhistor_backend_1 +echo y | sudo docker system prune +sudo docker-compose up --force-recreate -d --build backend