Merge pull request 'ci: push the image with crane (plain-HTTP in-cluster registry)' (#185) from ci/image-push-crane into main
Reviewed-on: #185
This commit was merged in pull request #185.
This commit is contained in:
commit
18eb750ccb
1 file changed
+18
-4
@@ -289,7 +289,7 @@ jobs:
|
|||||||
|
|
||||||
image:
|
image:
|
||||||
# Builds Dockerfile.ci (the build job's amd64 binaries on distroless)
|
# Builds Dockerfile.ci (the build job's amd64 binaries on distroless)
|
||||||
# with the runner's Docker daemon instead of Kaniko rebuilding frontend
|
# with the runner's Docker daemon and pushes with crane instead of Kaniko rebuilding frontend
|
||||||
# and Go from the git context. Images are pushed only from main and tags,
|
# and Go from the git context. Images are pushed only from main and tags,
|
||||||
# and only once the PACKAGE_TOKEN secret (write:package) exists.
|
# and only once the PACKAGE_TOKEN secret (write:package) exists.
|
||||||
# The build job's version, so the API reports the release its agent
|
# The build job's version, so the API reports the release its agent
|
||||||
@@ -313,7 +313,7 @@ jobs:
|
|||||||
VERSION: ${{ needs.build.outputs.version }}
|
VERSION: ${{ needs.build.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
apk add --no-cache docker-cli docker-cli-buildx >/dev/null
|
apk add --no-cache docker-cli docker-cli-buildx crane >/dev/null
|
||||||
REGISTRY="${GITHUB_SERVER_URL#*://}"
|
REGISTRY="${GITHUB_SERVER_URL#*://}"
|
||||||
IMAGE="$(printf '%s/%s' "$REGISTRY" "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')"
|
IMAGE="$(printf '%s/%s' "$REGISTRY" "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')"
|
||||||
TAG="$VERSION"
|
TAG="$VERSION"
|
||||||
@@ -338,7 +338,21 @@ jobs:
|
|||||||
echo "PACKAGE_TOKEN is not set; built without pushing."
|
echo "PACKAGE_TOKEN is not set; built without pushing."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
printf '%s' "$PACKAGE_TOKEN" | docker login "$REGISTRY" -u "$GITHUB_ACTOR" --password-stdin
|
# crane instead of docker push: on main and tags GITHUB_SERVER_URL is
|
||||||
for t in $TAGS; do docker push "$t"; done ;;
|
# the in-cluster plain-HTTP address, which the runner's Docker
|
||||||
|
# daemon refuses ("server gave HTTP response to HTTPS client").
|
||||||
|
INSECURE=""
|
||||||
|
case "$GITHUB_SERVER_URL" in http://*) INSECURE="--insecure" ;; esac
|
||||||
|
printf '%s' "$PACKAGE_TOKEN" | crane auth login "$REGISTRY" -u "$GITHUB_ACTOR" --password-stdin $INSECURE
|
||||||
|
FIRST=""
|
||||||
|
for t in $TAGS; do
|
||||||
|
if [ -z "$FIRST" ]; then
|
||||||
|
docker save "$t" -o /tmp/image.tar
|
||||||
|
crane push $INSECURE /tmp/image.tar "$t"
|
||||||
|
FIRST="$t"
|
||||||
|
else
|
||||||
|
crane tag $INSECURE "$FIRST" "${t##*:}"
|
||||||
|
fi
|
||||||
|
done ;;
|
||||||
*) echo "Pull request: built without pushing." ;;
|
*) echo "Pull request: built without pushing." ;;
|
||||||
esac
|
esac
|
||||||
Reference in new issue
Block a user