From a83499ccd4646055f13fec9a29bb030be74be5a7 Mon Sep 17 00:00:00 2001 From: John Boyes Date: Wed, 17 Jan 2024 13:38:36 +0000 Subject: [PATCH] Check Docker image is correctly tagged latest A recent change, #405, which added ARM64 Docker images to the build process, introduced a bug whereby the new Docker images for each release are no longer being tagged `latest`, as they should be. This commit adds a test to catch this bug, and we will fix the bug in a subsequent commit. --- .github/workflows/github_tag_and_release.yml | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github_tag_and_release.yml b/.github/workflows/github_tag_and_release.yml index c4fb0092..6b3d89b6 100644 --- a/.github/workflows/github_tag_and_release.yml +++ b/.github/workflows/github_tag_and_release.yml @@ -6,13 +6,16 @@ on: # yamllint disable-line rule:truthy types: - closed +env: + docker_repo: agilepathway/pull-request-label-checker + jobs: tag: name: Tag semantic version runs-on: ubuntu-22.04 outputs: - tag: ${{ steps.tag.outputs.tag }} + semver: ${{ steps.tag.outputs.tag }} steps: - name: Tag uses: K-Phoen/semver-release-action@v1.3.2 @@ -65,6 +68,26 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@v5 with: - tags: agilepathway/pull-request-label-checker:${{ needs.tag.outputs.tag }} + tags: ${{env.docker_repo}}:${{ needs.tag.outputs.semver }} platforms: linux/amd64,linux/arm64 push: true + + check_latest_tag: + needs: [tag, build_and_push_docker_image] + runs-on: ubuntu-22.04 + steps: + + - name: Check Docker image for new release is tagged latest + id: check_docker_image_tagged_latest + # yamllint disable rule:line-length + run: | + docker pull ${{env.docker_repo}}:${{ needs.tag.outputs.semver }} + echo "IS_LATEST_TAGGED_CORRECTLY=$(docker image inspect ${{env.docker_repo}}:${{ needs.tag.outputs.semver }} | jq -r '.[] | (.RepoTags) | any( . == "${{env.docker_repo}}:latest") ')" >> "$GITHUB_OUTPUT" + # yamllint enable rule:line-length + + - name: Fail if latest is not tagged correctly + if: ${{ steps.check_docker_image_tagged_latest.outputs.IS_LATEST_TAGGED_CORRECTLY == 'false' }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('The newly released Docker image ${{ needs.tag.outputs.semver }} is not tagged latest. ')