From 6a7f3a69450cb0a70f6027a96913ea3d3e169171 Mon Sep 17 00:00:00 2001 From: "@matheusdoedev" Date: Thu, 28 Sep 2023 12:30:41 -0300 Subject: [PATCH] feat: it update deploy workflow --- .github/workflows/deploy.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3930d7d..92cdd0e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,7 +5,7 @@ on: branches: ['master'] env: - CONTAINER_NAME: medical-supplier-name + CONTAINER_NAME: medical-supplier-manager CONTAINER_TAG: latest permissions: @@ -40,13 +40,17 @@ jobs: runs-on: ubuntu-latest steps: - - name: SSH Deploy - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.AWS_EC2_HOST }} - username: ${{ secrets.AWS_EC2_USERNAME }} - key: ${{ secrets.SSH_KEY }} - port: ${{ secrets.SSH_PORT }} - script: | - sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }} - sudo docker run -d -p 80:80 ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }} + - name: Creating a private key + run: | + mkdir ~/.ssh + echo ${{ secrets.SSH_KEY }} > ~/.ssh/id_rsa + chmod 400 ~/.ssh/id_rsa + + - name: Acessing EC2 instance + run: ssh -i ~/.ssh/id_rsa ${{ secrets.AWS_EC2_USERNAME }}@${{ secrets.AWS_EC2_HOST }} + + - name: Pulling docker image + run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }} + + - name: Running container + run: sudo docker run -d -p 80:80 ${{ secrets.DOCKER_USERNAME }}/${{ env.CONTAINER_NAME }}