Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Docker push to Artifact Registry fails from GitHub Actions with a permission error

ErrorPermission 'artifactregistry.repositories.uploadArtifacts' denied on resource

Short answer

The identity your workflow authenticates as lacks the permission artifactregistry.repositories.uploadArtifacts on the target repository. Grant that identity the Artifact Registry Writer role on the repository, make sure Docker is set up for the repository's region host, and check that the image path names a repository that exists.

  • Applies to Google Cloud CLI, Artifact Registry, GitHub Actions
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the resource path in the error, then list which identities hold a role on that repository.

    gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_ID
  2. 2Match what you see, then jump to its fix

    1. 1The policy from the first step has no entry for the service account or principal your workflow usesThe workflow identity has no Writer role on the repositoryFix
    2. 2Writer exists on the repository, but for another service account, such as the one used for deploysThe role was granted to a different account than the one pushingFix
    3. 3The push goes to LOCATION-docker.pkg.dev, but no credential helper entry exists for that exact hostDocker is not set up for the repository's region hostFix
    4. 4The path in the error has a repository or location that is not in the repository listThe image path names a repository that does not existFix

What does the error look like?

  • Permission 'artifactregistry.repositories.uploadArtifacts' denied on resource

Cause 1 of 4

The workflow identity has no Writer role on the repository

1Check

Compare the email in your auth step (the service account) with the members in the policy. Reading images is not enough: pushing needs a role that contains uploadArtifacts, and Writer is the standard choice.

gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_ID

2Fix

Grant Artifact Registry Writer to that identity on the repository, or on the project if it should apply to every repository.

gcloud artifacts repositories add-iam-policy-binding REPOSITORY \
  --location=LOCATION \
  --member=serviceAccount:SA_NAME@PROJECT_ID.iam.gserviceaccount.com \
  --role=roles/artifactregistry.writer

3Verify

Re-run the failed workflow job. The push step should now upload the image.

docker push LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE:TAG

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 2 of 4

The role was granted to a different account than the one pushing

1Check

Roles that contain uploadArtifacts include Writer, Repository Administrator and Create-on-Push Writer. Describe the role to confirm its permissions.

gcloud iam roles describe roles/artifactregistry.writer

2Fix

Bind the role to the exact email used in the workflow's auth step, not to a similarly named account.

gcloud artifacts repositories add-iam-policy-binding REPOSITORY \
  --location=LOCATION \
  --member=serviceAccount:SA_NAME@PROJECT_ID.iam.gserviceaccount.com \
  --role=roles/artifactregistry.writer

3Verify

Run the workflow again and confirm the push step passes.

gcloud artifacts repositories get-iam-policy REPOSITORY --location=LOCATION --project=PROJECT_ID

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 3 of 4

Docker is not set up for the repository's region host

1Check

Authentication works per regional host. Look for the host in the credHelpers section of the Docker config on the runner.

cat ~/.docker/config.json

2Fix

Run the credential helper setup for the same host as the image path, after the auth step and before the push.

gcloud auth configure-docker LOCATION-docker.pkg.dev

3Verify

The host now appears in credHelpers, and the push step authenticates.

cat ~/.docker/config.json

Confirmed by docs.cloud.google.com

Did this fix it?

Cause 4 of 4

The image path names a repository that does not exist

1Check

The image path format is LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE. List the repositories and compare each part.

gcloud artifacts repositories list --project=PROJECT_ID

2Fix

Correct the path in the workflow, or create the Docker repository first if it is missing.

gcloud artifacts repositories create REPOSITORY --repository-format=docker \
  --location=LOCATION --project=PROJECT_ID

3Verify

Repository appears in the list; then push again.

gcloud artifacts repositories list --project=PROJECT_ID

Confirmed by docs.cloud.google.com

Did this fix it?

How do I stop it coming back?

  • Grant Writer on the single repository, not on the whole project.
  • Keep the registry host, project and repository in one workflow env variable so the path is spelled once.
  • Run gcloud auth configure-docker in the workflow for the exact region you push to.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

docker pull or push to ghcr.io fails with 'denied'

Error response from daemon: denied

ghcr.io refuses a pull or push when Docker is not logged in, when the token lacks the package scope, or when the workflow's GITHUB_TOKEN has no packages permission or no access to that package.

4 causes, each with a fix

Servers

A GitHub Actions workflow builds the Docker image but cannot push it

The push step fails right after the login step

Four things stop a push from GitHub Actions: build-push-action does not push unless push is true, the Docker Hub login used a password instead of an access token, the workflow token lacks packages write for ghcr.io, or the run comes from a fork, where the token is read-only.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.