From e1596cbadd0129146343a2c7c6c75806df873031 Mon Sep 17 00:00:00 2001 From: Bradley Bown Date: Fri, 18 Oct 2024 11:07:39 +0100 Subject: [PATCH] Testing pull image without docker login --- .github/actions/check-image-tags-exist/action.yml | 12 ------------ .github/actions/image-tag-and-push/action.yml | 9 ++------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/.github/actions/check-image-tags-exist/action.yml b/.github/actions/check-image-tags-exist/action.yml index 2703b3f75..e6de9e5e5 100644 --- a/.github/actions/check-image-tags-exist/action.yml +++ b/.github/actions/check-image-tags-exist/action.yml @@ -22,25 +22,13 @@ outputs: runs: using: 'composite' steps: - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ inputs.docker_username }} - password: ${{ inputs.docker_password }} - name: Check last commit image tag exists id: last_commit_image_exists shell: bash continue-on-error: true run: | echo last_commit_tag_exists=$(docker pull ${{ inputs.image_name }}:${{ inputs.last_commit_tag }} > /dev/null ; echo $?) >> $GITHUB_OUTPUT - - name: Check ancestor commit image tag exists - shell: bash - id: ancestor_commit_image_exists - continue-on-error: true - run: | - echo common_ancestor_commit_tag_exists=$(docker pull ${{ inputs.image_name }}:${{ inputs.common_ancestor_tag }} > /dev/null ; echo $?) >> $GITHUB_OUTPUT - name: Show outputs shell: bash run: | echo "last_commit_tag_exists: ${{ steps.last_commit_image_exists.outputs.last_commit_tag_exists }}" - echo "common_ancestor_commit_tag_exists: ${{ steps.ancestor_commit_image_exists.outputs.common_ancestor_commit_tag_exists }}" diff --git a/.github/actions/image-tag-and-push/action.yml b/.github/actions/image-tag-and-push/action.yml index 79ed8172b..e30b7dca3 100644 --- a/.github/actions/image-tag-and-push/action.yml +++ b/.github/actions/image-tag-and-push/action.yml @@ -33,6 +33,7 @@ runs: using: 'composite' steps: - name: Login to Docker Hub + if: ${{ github.ref == 'refs/heads/main' && inputs.last_commit_tag_exists == '0' }} uses: docker/login-action@v2 with: username: ${{ inputs.docker_username }} @@ -41,19 +42,13 @@ runs: shell: bash run: | echo IMAGE_TAGGED=false >> $GITHUB_ENV - - name: Tag Docker image with last commit tag with the commit hash plus - shell: bash - if: ${{ inputs.last_commit_tag != '0000000' && inputs.last_commit_tag_exists == '0' }} - run: | - docker buildx imagetools create --tag ${{ inputs.image_name }}:${{ inputs.commit_tag }} ${{ inputs.image_name }}:${{ inputs.last_commit_tag }} - echo IMAGE_TAGGED=true >> $GITHUB_ENV - name: Tag Docker image with develop if on main branch shell: bash if: ${{ github.ref == 'refs/heads/main' && inputs.last_commit_tag_exists == '0' }} run: | docker buildx imagetools create --tag ${{ inputs.image_name }}:${{ inputs.develop_tag }} ${{ inputs.image_name }}:${{ inputs.last_commit_tag }} + docker buildx imagetools create --tag ${{ inputs.image_name }}:${{ inputs.commit_tag }} ${{ inputs.image_name }}:${{ inputs.last_commit_tag }} echo IMAGE_TAGGED=true >> $GITHUB_ENV - - name: Set output from environment variable shell: bash id: set-output