From 1b533cde7b1d282388d3231a3c71af272fd4abfb Mon Sep 17 00:00:00 2001 From: MAXOUXAX <24844231+MAXOUXAX@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:58:01 +0100 Subject: [PATCH] ci: added GitHub Workflow to automatically deploy backend --- .github/workflows/backend-deployment.yml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/backend-deployment.yml diff --git a/.github/workflows/backend-deployment.yml b/.github/workflows/backend-deployment.yml new file mode 100644 index 00000000..cf4a4136 --- /dev/null +++ b/.github/workflows/backend-deployment.yml @@ -0,0 +1,35 @@ +name: Backend Deployment + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up SSH connection + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: SSH into server and update code + uses: appleboy/ssh-action@v0.2.0 + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USERNAME }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + script: | + cd /home/ubuntu/.docker/datsmysong + git pull + + - name: Stop containers + run: docker-compose -f /home/ubuntu/.docker/datsmysong/docker-compose.yml down + + - name: Start containers + run: docker-compose -f /home/ubuntu/.docker/datsmysong/docker-compose.yml up -d