Skip to content

Configure the registry once and derive image names automatically - #4

Merged
olljanat-ai merged 1 commit into
mainfrom
claude/tender-meitner-ajhg0z
Nov 12, 2026
Merged

olljanat-ai merged 1 commit into
mainfrom
claude/tender-meitner-ajhg0z

Conversation

@olljanat-ai

Copy link
Copy Markdown
Member

Summary

Neither GitHub nor Azure DevOps can store secrets for an action or extension at install time. This PR uses the closest supported alternative: the registry and its credentials live once in organization or project settings under well-known names, and every pipeline picks them up without extra inputs.

Automatic image names

When image is empty, the name is derived from the source:

Platform Image name
GitHub <registry>/<owner>/<repository>
Azure DevOps <registry>/<project>/<repository>
Docker Hub docker.io/<namespace>/<repository> (Docker Hub allows only one level)
  • Names are lower-cased and characters that aren't allowed are replaced with -.
  • image can also be a short name below the registry (tools/api) or a full reference.
  • The registry is resolved in this order:
    1. the registry input,
    2. the CONTAINER_REGISTRY variable,
    3. the Azure service connection's registry,
    4. ghcr.io on GitHub.
  • On GitHub with no configuration at all, uses: onek8s/container-build-extension@v0 alone pushes to ghcr.io/<owner>/<repo>.

Credentials configured once

  • CONTAINER_REGISTRY_USERNAME / CONTAINER_REGISTRY_PASSWORD are read from env and pipeline variables. On Azure this includes secret variables, which the agent passes to tasks as SECRET_*. They are removed from the environment once read.
  • They are only sent to the registry named in CONTAINER_REGISTRY. An image on another registry never receives them.
  • Precedence: explicit inputs or service connection > variables > GitHub token (ghcr.io only).
  • Azure DevOps: add variables: - group: container-registry plus - task: ContainerBuild@0, or use only containerRegistry: <connection>.
  • GitHub: a new reusable workflow .github/workflows/container-build.yml. With org variables and secrets in place, a repo needs only uses: onek8s/container-build-extension/.github/workflows/container-build.yml@v0 and secrets: inherit. Details:
    • It checks out the caller's sources into a subdirectory, so the action checkout is never part of the build context.
    • It passes the credentials as env vars, so the registry-scoping rule applies.
    • It uploads the SBOM.

Testing

  • 65 unit tests. New cases cover registry normalization, naming and sanitizing, precedence, credential scoping (including that credentials are not sent to another registry), Azure secret variables and service-connection default registries.
  • New CI e2e jobs:
    • The Azure task with variable-group-style credentials and automatic naming pushes to an authenticated registry, and the password never appears unmasked in the log.
    • The reusable workflow runs from this PR's SHA and the test checks the derived image name.
  • Locally, against a real authenticated registry: automatic naming plus variable credentials pushed localhost:5001/e2e-project/demo_repo. Pushing to a different registry did not use the org credentials.

Generated by Claude Code

- Image name defaults to <registry>/<owner|project>/<repository>
  (GitHub owner/repo, Azure DevOps project/repo; repository only on
  Docker Hub). 'image' may also be a name below the registry.
- Registry: 'registry' input > CONTAINER_REGISTRY variable > Azure
  service connection registry > ghcr.io on GitHub.
- Organization/project wide credentials via CONTAINER_REGISTRY_USERNAME
  and CONTAINER_REGISTRY_PASSWORD (Azure secret variables included),
  only ever sent to the registry named in CONTAINER_REGISTRY.
- Reusable GitHub workflow so a repository only needs
  'uses: .../container-build.yml@v0' with 'secrets: inherit'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HpAsQazVvi679PqLz7o1C1
@olljanat-ai
olljanat-ai merged commit 26273d7 into main Nov 12, 2026
5 checks passed
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