Skip to content

Commit 13d135d

Browse files
committed
fix unecessary behaviour
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
1 parent 0718db9 commit 13d135d

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

.github/workflows/publish-dev.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,29 @@ jobs:
116116
--push .
117117
- name: Inspect binaries
118118
if: needs.check.outputs.build_multi_arch == 'true'
119-
run: "# Image for one arhitecture has digest in config field.\n# Image with multiple manifests has digest in each manifest.\nmanifests=$(docker buildx imagetools inspect \"${GHCR_IO_IMAGE_NAME}\" --raw)\nif grep manifests <<<\"${manifests}\" 2>&1 >/dev/null ; then\n jq -r '.manifests[]? | .digest + \" \" + .platform.os + \"/\" + .platform.architecture' <<<\"${manifests}\" \\\n | while read digest platform ; do\n image=${GHCR_IO_IMAGE_NAME}@${digest}\n if [[ ${BUILDX_PLATFORMS} != *\"${platform}\"* ]] ; then\n echo \"=====================================\"\n echo \"Ignore image for non-runnable platform ${platform}\"\n echo \" ${image}\"\n echo \"=====================================\"\n continue \n fi\n echo \"=====================================\"\n echo \"Inspect image for platform ${platform}\"\n echo \" ${image}\"\n echo \"=====================================\"\n docker run --rm --platform ${platform} --entrypoint sh ${image} -c \\\n 'apk add file > /dev/null; file /bin/kubectl; file /bin/busybox; file /shell-operator'\n done\nelse\n echo Not a multi-arhitecture image.\n #echo $(echo -n \"${manifests}\" | openssl dgst -sha256) ' linux/amd64'\nfi\n"
119+
run: |
120+
# Image for one arhitecture has digest in config field.
121+
# Image with multiple manifests has digest in each manifest.
122+
manifests=$(docker buildx imagetools inspect "${GHCR_IO_IMAGE_NAME}" --raw)
123+
if grep manifests <<<"${manifests}" 2>&1 >/dev/null ; then
124+
jq -r '.manifests[]? | .digest + " " + .platform.os + "/" + .platform.architecture' <<<"${manifests}" \
125+
| while read digest platform ; do
126+
image=${GHCR_IO_IMAGE_NAME}@${digest}
127+
if [[ ${BUILDX_PLATFORMS} != *"${platform}"* ]] ; then
128+
echo "====================================="
129+
echo "Ignore image for non-runnable platform ${platform}"
130+
echo " ${image}"
131+
echo "====================================="
132+
continue
133+
fi
134+
echo "====================================="
135+
echo "Inspect image for platform ${platform}"
136+
echo " ${image}"
137+
echo "====================================="
138+
docker run --rm --platform ${platform} --entrypoint sh ${image} -c \
139+
'apk add file > /dev/null; file /bin/kubectl; file /bin/busybox; file /shell-operator'
140+
done
141+
else
142+
echo Not a multi-arhitecture image.
143+
#echo $(echo -n "${manifests}" | openssl dgst -sha256) ' linux/amd64'
144+
fi

.github/workflows/publish-release.yaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,31 @@ jobs:
139139
--push \
140140
.
141141
- name: Inspect binaries
142-
run: "# Image for one arhitecture has digest in config field.\n# Image with multiple manifests has digest in each manifest.\nmanifests=$(docker buildx imagetools inspect \"${GHCR_IO_IMAGE_NAME}\" --raw)\nif grep manifests <<<\"${manifests}\" 2>&1 >/dev/null ; then\n jq -r '.manifests[]? | .digest + \" \" + .platform.os + \"/\" + .platform.architecture' <<<\"${manifests}\"\nelse\n echo $(echo -n \"${manifests}\" | openssl dgst -sha256 | sed s/^.stdin.*\\ //) ' linux/amd64'\nfi \\\n| while read digest platform ; do\n if [[ ${BUILDX_PLATFORMS} != *\"${platform}\"* ]] ; then\n echo \"=====================================\"\n echo \"Ignore image for non-runnable platform ${platform}\"\n echo \" ${image}\"\n echo \"=====================================\"\n continue \n fi\n image=${GHCR_IO_IMAGE_NAME}@${digest}\n echo \"=====================================\"\n echo \"Inspect image for platform ${platform}\"\n echo \" ${image}\"\n echo \"=====================================\"\n docker run --rm --platform ${platform} --entrypoint sh ${image} -c \\\n 'apk add file > /dev/null; file /bin/kubectl; file /bin/busybox; file /shell-operator'\ndone\n"
142+
run: |
143+
# Image for one arhitecture has digest in config field.
144+
# Image with multiple manifests has digest in each manifest.
145+
manifests=$(docker buildx imagetools inspect "${GHCR_IO_IMAGE_NAME}" --raw)
146+
if grep manifests <<<"${manifests}" 2>&1 >/dev/null ; then
147+
jq -r '.manifests[]? | .digest + " " + .platform.os + "/" + .platform.architecture' <<<"${manifests}"
148+
else
149+
echo $(echo -n "${manifests}" | openssl dgst -sha256 | sed s/^.stdin.*\ //) ' linux/amd64'
150+
fi \
151+
| while read digest platform ; do
152+
if [[ ${BUILDX_PLATFORMS} != *"${platform}"* ]] ; then
153+
echo "====================================="
154+
echo "Ignore image for non-runnable platform ${platform}"
155+
echo " ${image}"
156+
echo "====================================="
157+
continue
158+
fi
159+
image=${GHCR_IO_IMAGE_NAME}@${digest}
160+
echo "====================================="
161+
echo "Inspect image for platform ${platform}"
162+
echo " ${image}"
163+
echo "====================================="
164+
docker run --rm --platform ${platform} --entrypoint sh ${image} -c \
165+
'apk add file > /dev/null; file /bin/kubectl; file /bin/busybox; file /shell-operator'
166+
done
143167
- name: Copy image to Docker Hub
144168
env:
145169
DOCKER_USER: ${{ secrets.DOCKER_USER }}

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ update-k8s-version: go-check
5050
.PHONY: update-workflows-go-version
5151
update-workflows-go-version: yq
5252
for file in $$(find .github/workflows -name "*.yaml"); do \
53-
$(YQ) -i '(.jobs[]?.steps[]? | select(.uses | test("actions/setup-go")) | .with."go-version") = "$(GO_BUILDER_VERSION)"' $$file; \
53+
if grep -q "actions/setup-go" $$file; then \
54+
$(YQ) -i '(.jobs[]?.steps[]? | select(.uses | test("actions/setup-go")) | .with."go-version") = "$(GO_BUILDER_VERSION)"' $$file; \
55+
fi; \
5456
done
5557
echo "Updated go-version in workflow files to $(GO_BUILDER_VERSION)"
5658

0 commit comments

Comments
 (0)