Skip to content

Publish images under the repository owner and restrict workflow permissions - #50

Merged
umputun merged 2 commits into
masterfrom
ci-owner-and-permissions
Aug 20, 2026
Merged

Publish images under the repository owner and restrict workflow permissions#50
umputun merged 2 commits into
masterfrom
ci-owner-and-permissions

Conversation

@paskal

@paskal paskal commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Two changes to the build workflow.

Image owner. github.actor is the account that triggered the run, not the owner of the repository, so a push to master or a tag made by anyone else, a collaborator or a bot, builds image names in that account's namespace and attempts the ghcr.io and Docker Hub logins with that username against this repository's secrets. Pushes triggered by you hide the problem, because there both values are identical.

github.repository_owner keeps the canonical images exactly where they are, ghcr.io/umputun/baseimage/* and umputun/baseimage, and it preserves the part of the current behaviour that makes sense: whoever runs a fork still publishes into their own namespace. The Docker Hub half takes its owner from a DOCKERHUB_OWNER repository variable when one is set and falls back to the repository owner otherwise, so a fork whose Docker Hub account name differs from its GitHub owner can point it at the right account without editing the workflow. With no variable set, nothing changes here.

Permissions and lint. The workflow had no top-level permissions block, so the merge job ran with whatever the repository default grants. It now starts from contents: read, with packages: write added back on both jobs that push images. The push trigger listed branches and tags with no values, which behaves as match-all but fails actionlint as an empty string; ["**"] states the same intent. Together with quoting $GITHUB_OUTPUT and marking the two manifest expansions that have to word-split, actionlint is now clean on the workflow.

Action version bumps are left to the open dependabot PR #49.

paskal added 2 commits August 19, 2026 15:51
github.actor is the user who triggered the run, so a push to master or a
tag made by anyone other than the repository owner built image names in
that person's namespace, and the ghcr.io and Docker Hub logins were
attempted with their username against the repository secrets.

github.repository_owner keeps the canonical images at
ghcr.io/umputun/baseimage/* and umputun/baseimage while forks still
publish into the fork owner's own namespace. The Docker Hub half takes
its owner from the DOCKERHUB_OWNER repository variable when set, so a
fork whose Docker Hub account differs from its GitHub owner can point
it at the right account without touching the workflow.
The workflow had no top-level permissions block, so the merge job ran
with whatever the repository default grants; it now starts from
contents: read, with packages: write added back where images are pushed.

The push trigger listed branches and tags with no values, which works
but fails actionlint as an empty string; ["**"] states the same intent
and keeps the workflow clean under actionlint, along with quoting
$GITHUB_OUTPUT and marking the two manifest expansions that have to
word-split.
@umputun
umputun merged commit e190342 into master Aug 20, 2026
14 checks passed
@umputun
umputun deleted the ci-owner-and-permissions branch August 20, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants