From 646fe8eb174bf6b02ad84776113b36c4ff58c8db Mon Sep 17 00:00:00 2001 From: Simon Templer Date: Fri, 11 Oct 2024 10:04:24 +0200 Subject: [PATCH] feat(gradle): login to Docker Hub if credentials are provided ...because this may be needed if testcontainers tests are included. Testcontainers will pick up the docker login in case it needs to pull images based on the configure image pull policy. --- .github/workflows/gradle-library.yml | 14 ++++++++++++++ .github/workflows/gradle-service.yml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/gradle-library.yml b/.github/workflows/gradle-library.yml index e1548c4..602da9b 100644 --- a/.github/workflows/gradle-library.yml +++ b/.github/workflows/gradle-library.yml @@ -109,6 +109,20 @@ jobs: # fetch-depth 0 is required to fetch all tags (and to determine the version based on tags) fetch-depth: ${{ inputs.publish-tasks != '' && '0' || '1' }} + # + # Login to Docker Hub + # + # May be required for pulling images for testcontainers + # + - name: Login to DockerHub + if: env.DOCKER_HUB_USERNAME + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + # # Build, test and create Docker image # diff --git a/.github/workflows/gradle-service.yml b/.github/workflows/gradle-service.yml index 34bef2d..71ae373 100644 --- a/.github/workflows/gradle-service.yml +++ b/.github/workflows/gradle-service.yml @@ -125,6 +125,20 @@ jobs: done fi + # + # Login to Docker Hub + # + # May be required for pulling images for testcontainers + # + - name: Login to DockerHub + if: env.DOCKER_HUB_USERNAME + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + env: + DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} + # # Build, test and create Docker image #