Skip to content

[#1046] Read the latest release with the workflow token, and fail the step when it comes back empty - #1047

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/ci-release-version-auth
Sep 15, 2026
Merged

vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issues/ci-release-version-auth

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #1046

What fails

Run 34854564649 (#968), job build-docker: the step «Get latest release version» printed last release: with nothing after it, docker/metadata-action warned «No Docker image version has been generated», and the push failed with ERROR: failed to build: tag is needed when pushing to registry. The maven legs of the run were green and attempt 2 passed with no change to the branch.

The step reads api.github.com/repos/OpenIdentityPlatform/OpenDJ/releases/latest with an anonymous curl. The anonymous limit is 60 requests an hour per source address and is shared by every job the runner's address hosts; a rate-limited answer carries no "name", so the version is empty and the image has no tag. build-docker-alpine reads the release the same way.

The change

.github/workflows/build.yml, the «Get latest release version» step of build-docker and build-docker-alpine:

  • the step is given GH_TOKEN: ${{ github.token }} through env: — the shape the Windows-artifact wait already uses — and the curl sends it as Authorization: Bearer. The workflow token has a budget of its own; permissions: contents: read, which both jobs already declare, is enough to read the releases of a public repository, from a fork's read-only PR token included;
  • when the version is still empty the step stops with ::error::The latest release of OpenIdentityPlatform/OpenDJ could not be read, so there is no version to tag the image with and exit 1, so the next failure of this shape is reported at the step which caused it rather than at the push.

The read itself (curl -i | grep "name" | cut) and everything after it are as they were.

Checked

  • The workflow parses; both jobs carry the env and the new run.
  • The step's shell, run locally with a token in GH_TOKEN: last release: 5.1.2, the guard passes. The header is honoured: the authenticated call answers x-ratelimit-limit: 5000, the anonymous one 60.
  • The guard with an empty value prints the ::error and exits 1.
  • The build-docker and build-docker-alpine legs of this PR's own run exercise the step on a runner.

… token, and fail the step when it comes back empty

The build-docker and build-docker-alpine jobs tag the image they test with the name of the
latest release, read from the GitHub API with an anonymous curl. The anonymous limit is 60
requests an hour per source address and is shared by every job the address hosts; once it is
spent the answer carries no release, the version is empty, docker/metadata-action produces no
tag and buildx refuses the push with "tag is needed when pushing to registry" - a red leg with
no relation to the change under test (run 34854564649, attempt 1).

The step now sends the workflow token, which has a budget of its own, and stops with a named
error when the version is still empty, so the next failure of this shape is reported at the
step which caused it rather than at the push.
@vharseko
vharseko merged commit fef4292 into OpenIdentityPlatform:master Sep 15, 2026
34 of 35 checks passed
@vharseko
vharseko deleted the issues/ci-release-version-auth branch September 15, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build-docker fails with "tag is needed when pushing to registry" when the anonymous read of the latest release is rate limited

2 participants