Skip to content

Commit ab4047a

Browse files
committed
Don't create a new manifest if nothing changed
1 parent 4bc3477 commit ab4047a

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

.github/workflows/build.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,35 @@ jobs:
123123
working-directory: "${{ runner.temp }}/digests"
124124
run: |
125125
for subdir in */*; do
126+
echo "::group::Processing $subdir"
126127
pushd "$subdir"
127128
image_repo="$(cut -d/ -f1 <<< "$subdir")"
128129
image_tag="$(cut -d/ -f2 <<< "$subdir")"
129130
130-
image_fullrepo="ghcr.io/angrybytes/$image_repo"
131-
image_fullname="$image_fullrepo:$image_tag"
132-
docker buildx imagetools create -t "$image_fullname" $(printf "$image_fullrepo@sha256:%s " *)
133-
docker buildx imagetools inspect "$image_fullname"
134-
135-
image_fullrepo="angrybytes/$image_repo"
136-
image_fullname="$image_fullrepo:$image_tag"
137-
docker buildx imagetools create -t "$image_fullname" $(printf "$image_fullrepo@sha256:%s " *)
138-
docker buildx imagetools inspect "$image_fullname"
131+
# Push to GitHub Packages and docker.io
132+
for repo_base in ghcr.io/angrybytes angrybytes; do
133+
image_fullrepo="$repo_base/$image_repo"
134+
image_fullname="$image_fullrepo:$image_tag"
135+
echo "-- Pushing to $image_fullname"
136+
137+
# Don't create a new manifest if nothing changed.
138+
new_hashes="$(
139+
echo * \
140+
| sort | xargs printf 'sha256:%s '
141+
)"
142+
old_hashes="$(
143+
(docker buildx imagetools inspect --raw "$image_fullname" || echo '{"manifests":[]}') \
144+
| jq -r '.manifests[] | select(.platform.os != "unknown") | .digest' \
145+
| sort | xargs printf '%s '
146+
)"
147+
if [[ "$new_hashes" == "$old_hashes" ]]; then
148+
echo "No change"
149+
else
150+
docker buildx imagetools create -t "$image_fullname" $(printf "$image_fullrepo@sha256:%s " *)
151+
docker buildx imagetools inspect "$image_fullname"
152+
fi
153+
done
139154
140155
popd
156+
echo "::endgroup::"
141157
done

0 commit comments

Comments
 (0)