diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 016a0f8..494283a 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -289,7 +289,7 @@ jobs: image: # 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 only once the PACKAGE_TOKEN secret (write:package) exists. # The build job's version, so the API reports the release its agent @@ -313,7 +313,7 @@ jobs: VERSION: ${{ needs.build.outputs.version }} run: | 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#*://}" IMAGE="$(printf '%s/%s' "$REGISTRY" "$GITHUB_REPOSITORY" | tr 'A-Z' 'a-z')" TAG="$VERSION" @@ -338,7 +338,21 @@ jobs: echo "PACKAGE_TOKEN is not set; built without pushing." exit 0 fi - printf '%s' "$PACKAGE_TOKEN" | docker login "$REGISTRY" -u "$GITHUB_ACTOR" --password-stdin - for t in $TAGS; do docker push "$t"; done ;; + # crane instead of docker push: on main and tags GITHUB_SERVER_URL is + # 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." ;; esac