From bec47223b1b2a4f19cfee1108f419dfef2a9f0c2 Mon Sep 17 00:00:00 2001 From: Diego Neves Date: Fri, 12 Jul 2024 08:05:43 -0300 Subject: [PATCH] develop :green_heart: Atualiza fluxo de trabalho para uso do docker/build-push-action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O código foi alterado para utilizar a ação docker/build-push-action no CI ao invés do comando `docker build` e `docker push` diretos. Isso simplifica o script geral e fornece uma maneira padronizada, em conformidade com as melhores práticas, de realizar essas ações. --- .github/workflows/ci-hlg-docker.yaml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-hlg-docker.yaml b/.github/workflows/ci-hlg-docker.yaml index 3f38996..0d07295 100644 --- a/.github/workflows/ci-hlg-docker.yaml +++ b/.github/workflows/ci-hlg-docker.yaml @@ -30,9 +30,20 @@ jobs: shell: bash run: echo "BRANCH_NAME=$(echo ${GITHUB_BASE_REF#release/} | cut -d'/' -f2)" >> $GITHUB_ENV - - name: Push to Docker Hub - run: | - if [[ "${{ github.event.pull_request.merged == 'true' }}" ]]; then - docker build -t diegoneves/conectar-doacoes:${{ env.BRANCH_NAME }} . --build-arg DB_NAME=${{ env.DB_NAME }} --build-arg DB_PASSWORD=${{ env.DB_PASSWORD }} --build-arg DB_USERNAME=${{ env.DB_USERNAME }} - docker push diegoneves/conectar-doacoes:${{ env.BRANCH_NAME }} - fi \ No newline at end of file + - name: Build and push + id: docker_build +# if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.ref == 'refs/heads/release/*' + uses: docker/build-push-action@v4 + with: + push: true + tags: diegoneves/conectar-doacoes:${{ env.BRANCH_NAME }} + build-args: | + DB_NAME=${{ env.DB_NAME }} + DB_PASSWORD=${{ env.DB_PASSWORD }} + DB_USERNAME=${{ env.DB_USERNAME }} +# - name: Push to Docker Hub +# run: | +# if [[ "${{ github.event.pull_request.merged == 'true' }}" ]]; then +# docker build -t diegoneves/conectar-doacoes:${{ env.BRANCH_NAME }} . --build-arg DB_NAME=${{ env.DB_NAME }} --build-arg DB_PASSWORD=${{ env.DB_PASSWORD }} --build-arg DB_USERNAME=${{ env.DB_USERNAME }} +# docker push diegoneves/conectar-doacoes:${{ env.BRANCH_NAME }} +# fi \ No newline at end of file