From b6f23b536aecf317dd8168c17d7a924054384866 Mon Sep 17 00:00:00 2001 From: plduthoit <139240078+plduthoit@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:37:45 +0200 Subject: [PATCH] ci: Add gh action to deploy on dev and uat --- .github/workflows/deploy.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d102fd2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,32 @@ +name: Deploy to Server + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.8.1 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy to UAT + if: github.ref == 'refs/heads/main' + run: | + ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ + "cd /home/ubuntu/puc_uat && git fetch origin && git reset --hard origin/main && make deploy" + + - name: Deploy to Dev + if: github.event_name == 'workflow_dispatch' + run: | + ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ + "cd /home/ubuntu/puc_dev && git fetch origin && git reset --hard origin/${{ github.ref_name }} && make deploy"