Skip to content

Commit

Permalink
Fix publishing multiple tags (#528)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yhtang authored Feb 10, 2024
1 parent a2352a5 commit 2c0fcd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/_publish_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.):'
Expand All @@ -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"
Expand Down
32 changes: 15 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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() }}
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 2c0fcd1

Please sign in to comment.