mirror of
https://github.com/elgohr/Publish-Docker-Github-Action.git
synced 2026-03-12 18:07:12 -04:00
🐛 Respect no_push in multi platform builds
Fixes https://github.com/elgohr/Publish-Docker-Github-Action/issues/215
This commit is contained in:
@@ -192,7 +192,11 @@ build() {
|
||||
done
|
||||
if uses "${INPUT_PLATFORMS}"; then
|
||||
local PLATFORMS="--platform ${INPUT_PLATFORMS}"
|
||||
docker buildx build --push --metadata-file metadata.json ${PLATFORMS} ${INPUT_BUILDOPTIONS} ${BUILDPARAMS} ${BUILD_TAGS} ${CONTEXT}
|
||||
local PUSHING="--push"
|
||||
if usesBoolean "${INPUT_NO_PUSH}"; then
|
||||
PUSHING=""
|
||||
fi
|
||||
docker buildx build ${PUSHING} --metadata-file metadata.json ${PLATFORMS} ${INPUT_BUILDOPTIONS} ${BUILDPARAMS} ${BUILD_TAGS} ${CONTEXT}
|
||||
else
|
||||
docker build ${INPUT_BUILDOPTIONS} ${BUILDPARAMS} ${BUILD_TAGS} ${CONTEXT}
|
||||
fi
|
||||
|
||||
51
test.bats
51
test.bats
@@ -696,6 +696,57 @@ EOT
|
||||
expectMockArgs ""
|
||||
}
|
||||
|
||||
@test "it respects no_push when building multiple platforms" {
|
||||
export GITHUB_REF='refs/heads/main'
|
||||
export INPUT_PLATFORMS='linux/amd64,linux/arm64'
|
||||
export INPUT_NO_PUSH='true'
|
||||
|
||||
cat <<EOT >> metadata.json
|
||||
{
|
||||
"containerimage.buildinfo/linux/amd64": {
|
||||
"frontend": "dockerfile.v0",
|
||||
"attrs": {
|
||||
"filename": "Dockerfile"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"type": "docker-image",
|
||||
"ref": "docker.io/library/alpine:latest",
|
||||
"pin": "sha256:7580ece7963bfa863801466c0a488f11c86f85d9988051a9f9c68cb27f6b7872"
|
||||
}
|
||||
]
|
||||
},
|
||||
"containerimage.buildinfo/linux/arm64": {
|
||||
"frontend": "dockerfile.v0",
|
||||
"attrs": {
|
||||
"filename": "Dockerfile"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"type": "docker-image",
|
||||
"ref": "docker.io/library/alpine:latest",
|
||||
"pin": "sha256:7580ece7963bfa863801466c0a488f11c86f85d9988051a9f9c68cb27f6b7872"
|
||||
}
|
||||
]
|
||||
},
|
||||
"containerimage.descriptor": {
|
||||
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
|
||||
"digest": "sha256:aa2c7631cc1bbf588192ec7e55b428ad92fe63834200303f28e93444d7fc114a",
|
||||
"size": 741
|
||||
},
|
||||
"containerimage.digest": "sha256:aa2c7631cc1bbf588192ec7e55b428ad92fe63834200303f28e93444d7fc114a",
|
||||
"image.name": "my/repository:latest"
|
||||
}
|
||||
EOT
|
||||
|
||||
run /entrypoint.sh
|
||||
|
||||
expectMockCalledContains "/usr/local/mock/docker login -u USERNAME --password-stdin
|
||||
/usr/local/mock/docker buildx build --metadata-file metadata.json --platform linux/amd64,linux/arm64 -t my/repository:latest .
|
||||
/usr/local/mock/docker logout"
|
||||
expectMockArgs ""
|
||||
}
|
||||
|
||||
expectStdOutIs() {
|
||||
local expected=$(echo "${1}" | tr -d '\n')
|
||||
local got=$(echo "${output}" | tr -d '\n')
|
||||
|
||||
Reference in New Issue
Block a user