From 865659392898a1159368e7ddcddffd0c18093f93 Mon Sep 17 00:00:00 2001 From: Lars Albino Lemos Date: Wed, 23 Aug 2023 10:38:57 +0200 Subject: [PATCH] Updated workflow for dev branch, deployment on dev server --- .github/workflows/ohri-dev.yml | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/.github/workflows/ohri-dev.yml b/.github/workflows/ohri-dev.yml index 71bae8b21..10db3a747 100644 --- a/.github/workflows/ohri-dev.yml +++ b/.github/workflows/ohri-dev.yml @@ -117,3 +117,70 @@ jobs: cache-to: type=gha,mode=max - name: Save image digest run: echo "::set-output name=image::${{ steps.build-and-push.output.digest }}" + + dev_server_status: + if: github.ref == 'refs/heads/dev-deploy' + runs-on: ubuntu-latest + + steps: + - name: Wait for 5 minutos - Let Images reflect on Docker Hub + run: sleep 300 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Copy files to /home/runner/ + run: | + ls -la -t + cp -r $GITHUB_WORKSPACE/.ssh/ /home/runner/ + + - name: List contents of /home/runner/ + run: ls -la /home/runner/ + + - name: webfactory/ssh-agent + uses: webfactory/ssh-agent@v0.8.0 + with: + ssh-private-key: ${{ secrets.LL_SSH_PRIVATE_KEY }} + + - name: Check SSH to remote OHRI Dev status + run: | + ssh-keygen -R 172.19.0.16 + + dev_server_connection_dev: + runs-on: ubuntu-latest + needs: dev_server_status + steps: + - name: SSH to remote OHRI Dev server + run: | + ssh -o StrictHostKeyChecking=no -T llemos@172.19.0.16 -p 2216 -J llemos@20.172.182.46 -p 2202 + ls -la -t && \ + cd /opt && \ + ls -la -t + + dev_deploy: + runs-on: ubuntu-latest + needs: dev_server_status + + if: (github.event_name == 'push' || github.event.pull_request.merged) + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: webfactory/ssh-agent + uses: webfactory/ssh-agent@v0.8.0 + + with: + ssh-private-key: ${{ secrets.LL_SSH_PRIVATE_KEY }} + + - name: SSH to remote OHRI Dev server via jump host + run: | + ssh -p 2216 \ + -o "UserKnownHostsFile=/dev/null" \ + -o "StrictHostKeyChecking=no" \ + -o "ProxyCommand=ssh -o StrictHostKeyChecking=no -W %h:%p llemos@20.172.182.46 -p 2202" \ + llemos@172.19.0.16 "\ + cd /opt && \ + docker compose -f docker-compose-ohri-dev.yml pull && \ + docker compose -f docker-compose-ohri-dev.yml stop && \ + docker compose -f docker-compose-ohri-dev.yml up -d" + \ No newline at end of file