From 2c0fcd11aa1c9efceb66bca177a18f28b9f6af8f Mon Sep 17 00:00:00 2001 From: "Yu-Hang \"Maxin\" Tang" Date: Fri, 9 Feb 2024 20:42:16 -0800 Subject: [PATCH] Fix publishing multiple tags (#528) In CI, there is currently a YAML-related issue that causes only the dated tag to be published during the nightly run, while the non-dated tag was not created. This PR fixes that. --- .github/workflows/_publish_container.yaml | 13 +++------ .github/workflows/ci.yaml | 32 +++++++++++------------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/.github/workflows/_publish_container.yaml b/.github/workflows/_publish_container.yaml index 0cb7de23a..6d3233231 100644 --- a/.github/workflows/_publish_container.yaml +++ b/.github/workflows/_publish_container.yaml @@ -3,6 +3,10 @@ name: ~publish images from internal to public repo on: workflow_call: inputs: + SOURCE_IMAGE: + type: string + description: 'Source docker image:' + required: true TARGET_IMAGE: type: string description: 'Target docker image (jax/t5x/etc.):' @@ -11,15 +15,6 @@ on: type: string description: 'Target docker tags in docker/metadata-action format:' required: true - SOURCE_IMAGE: - type: string - description: 'Source docker image:' - required: true - # EXPOSE_SINGLE_ARCH_IMAGES: - # type: boolean - # description: 'Also expose single-arch images:' - # required: false - # default: false outputs: DOCKER_TAGS: description: "Tags of the image published" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b79610d9b..2dd4f8096 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -89,7 +89,6 @@ jobs: BUMP_MANIFEST: ${{ needs.metadata.outputs.BUMP_MANIFEST == 'true' }} secrets: inherit - make-publish-configs: runs-on: ubuntu-22.04 if: ${{ !cancelled() }} @@ -143,8 +142,9 @@ jobs: # source_image is a list of all platform-specific tags source_image=$(echo "${matching_tags}" | jq -c "[.tag]" | jq -s 'add') # if the build job failed without producing any images, skip this flavor - if [[ $(echo "$source_image" | jq 'length') -gt 0 ]]; then - echo "PUBLISH image $flavor $stage containers" + n_source_images=$(echo "$source_image" | jq 'length') + if [[ $n_source_images -gt 0 ]]; then + echo "PUBLISH image $flavor with $n_source_images $stage containers" # tag priority is the highest priority of all platform-specific tags priority=$(echo "${matching_tags}" | jq -r ".priority" | jq -s 'max') @@ -160,22 +160,16 @@ jobs: ;; esac - # a list of aliases to created for the multi-arch image - target_tags=$(echo "[ - \"type=raw,value=${flavor},priority=${priority}\", - \"type=raw,value=${flavor}-${{ needs.metadata.outputs.BUILD_DATE }},priority=${priority}\" - ]" | jq -c - ) - PUBLISH_CONFIGS=$( echo ${PUBLISH_CONFIGS} | jq -c ". + [{ - \"source_image\": ${source_image}, + \"flavor\": \"${flavor}\", \"target_image\": \"${target_image}\", - \"target_tags\": ${target_tags} + \"priority\": \"${priority}\", + \"source_image\": ${source_image} }]" ) else - echo "SKIPPED image $flavor without any $stage containers" + echo "SKIPPED image $flavor with 0 $stage containers" fi done done @@ -184,17 +178,21 @@ jobs: echo ${PUBLISH_CONFIGS} | jq echo "PUBLISH_CONFIGS=${PUBLISH_CONFIGS}" >> $GITHUB_OUTPUT - publish: - needs: [make-publish-configs] + publish-containers: + needs: + - metadata + - make-publish-configs if: ${{ !cancelled() && needs.make-publish-configs.outputs.PUBLISH_CONFIGS.config != '{"config":[]}' }} strategy: fail-fast: false matrix: ${{ fromJson(needs.make-publish-configs.outputs.PUBLISH_CONFIGS) }} uses: ./.github/workflows/_publish_container.yaml with: + SOURCE_IMAGE: ${{ join(matrix.config.source_image, ' ') }} TARGET_IMAGE: ${{ matrix.config.target_image }} - TARGET_TAGS: ${{ join(matrix.config.target_tags, '\n') }} - SOURCE_IMAGE: ${{ join(matrix.config.source_image, '\n') }} + TARGET_TAGS: | + type=raw,value=${{ matrix.config.flavor }},priority=${{ matrix.config.priority }} + type=raw,value=${{ matrix.config.flavor }}-${{ needs.metadata.outputs.BUILD_DATE }},priority=${{ matrix.config.priority }} finalize: needs: [metadata, amd64, arm64]