Skip to content

Publish with the ACR identities - #15

Merged
MarceloRGonc merged 3 commits into
mainfrom
chore/publish-with-the-acr-identities
Sep 10, 2026
Merged

MarceloRGonc merged 3 commits into
mainfrom
chore/publish-with-the-acr-identities

Conversation

@MarceloRGonc

Copy link
Copy Markdown
Contributor

Part of OPS-4801. Merge only after openops-cloud/devops#291 is applied — that PR creates the credentials this uses.

Why

Every job in this workflow authenticated as github-actions-openops, with a client secret:

creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}",...}'

That identity holds, at subscription scope:

Container Registry Repository Writer   → /subscriptions/85ec64cc…
Contributor                            → /subscriptions/85ec64cc…
Azure Kubernetes Service Cluster User  → /subscriptions/85ec64cc…

The subscription-wide Writer is the only reason promote can write to the public registry — every other repository lost that path in openops-cloud/devops#289, which took the public-registry roles off the shared CI identity. Both assignments are on the list to remove, and this workflow would have broken with no other symptom.

What changes

Job Identity Reaches
build, manifest AZURE_ACR_CLIENT_ID private registry only
promote AZURE_ACR_RELEASE_CLIENT_ID public registry, behind environment: release

OIDC in both cases — no client secret, nothing to rotate. permissions: id-token: write per job, since the workflow-level block only grants contents: read.

environment: release is not optional

The release credential's subject is repo:openops-cloud/openops-mcp:environment:release. Without the environment declared on the job the presented token doesn't match and azure/login fails exactly the way a missing credential does. It's also where an approval gate for publishing to the registry customers pull from belongs.

No new role assignments

The release identity already holds what promote needs: docker buildx imagetools create across registries wants Container Registry Repository Writer on the public registry and content/read on the private one, and each az acr login wants registries/read on its own registry. Its three existing assignments cover all of it.

Registry names come from organisation variables

vars.ACR_NAME, vars.ACR_LOGIN_SERVER, vars.ACR_PUBLIC_NAME, vars.ACR_PUBLIC_LOGIN_SERVER instead of hardcoded hostnames, so this repository tracks the rest of the estate. An unset value fails the step via ${VAR:?} rather than building /openops-mcp and failing on a reference nobody recognises.

One capability lost

A workflow_dispatch from a branch other than main no longer authenticates: the credential's subject is refs/heads/main, and a dispatch presents the ref it ran from. Per-branch credentials aren't viable — there are 20 per application registration for the whole organisation. ci.yml already builds every branch and pull request, just without pushing, and the header comment now documents the restriction instead of promising branch builds.

Also needed, not in this PR

A release environment on this repository — it currently has only copilot. A job declaring environment: release creates it implicitly on first run but without required reviewers, so it's worth creating deliberately with the same protection the other repositories' release environments have.

🤖 Generated with Claude Code

Every job authenticated as github-actions-openops, with a client secret. That
identity holds Contributor and Container Registry Repository Writer at
*subscription* scope, which is the only reason the promote job can write to the
public registry - and both assignments are being removed, so this workflow
would have broken with no other symptom.

Now the same two identities every other repository uses, by OIDC with nothing
to rotate:

  build, manifest   AZURE_ACR_CLIENT_ID          private registry only
  promote           AZURE_ACR_RELEASE_CLIENT_ID  public registry, environment: release

environment: release is not optional. The release credential's subject is
repo:openops-cloud/openops-mcp:environment:release, so without the environment
declared the token does not match and azure/login fails the same way a missing
credential does. It is also where an approval gate for publishing publicly
belongs.

Registry names come from the organisation variables rather than being
hardcoded, so this repository tracks the rest of the estate, and an unset one
fails the step instead of building "/openops-mcp".

One capability is lost: a dispatch from a branch other than main no longer
authenticates, because the credential's subject is refs/heads/main and a
dispatch presents its own ref. ci.yml already builds branches without pushing.
The header says so.

Requires openops-cloud/devops#291 applied first - it creates all three
credentials - and a release environment on this repository.

Part of OPS-4801

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 10, 2026 09:22
@linear

linear Bot commented Sep 10, 2026

Copy link
Copy Markdown

OPS-4801

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Several az acr login steps rely on org vars for registry names without the same explicit fail-fast validation used elsewhere in the workflow, which can lead to harder-to-diagnose misconfiguration failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the Publish GitHub Actions workflow to publish images to Azure Container Registry using per-job OIDC identities and organization-level registry variables, reducing credential sprawl and scoping release promotions behind a protected environment.

Changes:

  • Switched Azure auth from client-secret creds: to OIDC (client-id + id-token: write) with separate identities for build vs release promotion.
  • Parameterized private/public ACR names and login servers via org vars.*, and added fail-fast checks for login-server variables before Docker tagging/promotion.
  • Added environment: release to the promote job to match the release federated credential subject and enable approval gating.
File summaries
File Description
.github/workflows/publish.yml Migrates publish authentication to OIDC identities and uses org registry variables for private/public ACR targeting.
Review details

Suppressed comments (2)

.github/workflows/publish.yml:119

  • Same as in build: az acr login depends on vars.ACR_NAME but doesn’t fail fast if it’s unset. Adding an explicit ${VAR:?} guard here makes misconfiguration errors much clearer.
      - name: ACR login
        run: az acr login --name ${{ vars.ACR_NAME }}

.github/workflows/publish.yml:163

  • The promote job now uses vars.ACR_NAME and vars.ACR_PUBLIC_NAME, but only the login servers are validated later. If either registry name var is empty, the failure will come from Azure CLI with a less specific message. Consider validating both names here as well.
      - name: ACR login
        run: |
          az acr login --name ${{ vars.ACR_NAME }}
          az acr login --name ${{ vars.ACR_PUBLIC_NAME }}
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/publish.yml Resolved
From Copilot on #15. I guarded the login-server variables and left the
registry names interpolated straight into the shell, so an unset ACR_NAME gave
`az acr login --name` and an az CLI complaint about a missing argument that
names no variable.

Now every registry variable reaches the shell through env and is checked the
same way. Nothing in a run block interpolates ${{ }} any more, which is also
the shape that keeps expression values out of the script itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The estate promotes with `az acr import`; this job pulled the manifest through
the runner with `docker buildx imagetools create` and pushed it to the public
registry. Same result, more moving parts: blobs cross the runner, buildx has to
be installed, and both registries need a docker login.

Import is an ARM call the registry performs server-side. It copies a manifest
list whole with its digest intact, so the promote job is now one login and one
step, and it needs only the two Data Importer roles rather than data-plane
Writer on the public registry.

Also drops a stale reference to re-tagging "the tested ECR image".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@MarceloRGonc
MarceloRGonc merged commit 8e7c930 into main Sep 10, 2026
8 checks passed
@MarceloRGonc
MarceloRGonc deleted the chore/publish-with-the-acr-identities branch September 10, 2026 09:42
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.

3 participants