I am trying to push docker container to Artifact Registry on GCP but I got an error on step Push Docker Image to Artifact Registry
denied: Permission "artifactregistry.repositories.uploadArtifacts" denied on resource "projects/PROJECT_ID/locations/asia-south1/repositories/images" (or it may not exist) Error: Process completed with exit code 1.
name: Build image and push to Artifact Registry of GCP
on:
push:
branches:
- master
jobs:
build-push-artifact:
name : Build and push Artifact Registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.ACCOUNT_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'Use gcloud CLI'
run: 'gcloud info'
- name: build Docker Image
run: docker build -t MY_IMAGE:latest .
- name: Configure Docker Client of Gcloud
run: |-
gcloud auth configure-docker --quiet
gcloud auth configure-docker asia-south1-docker.pkg.dev --quiet
- name: Push Docker Image to Artifact Registry
env:
GIT_TAG: v0.1.0
run: |-
docker tag MY_IMAGE:latest asia-south1-docker.pkg.dev/PROJECT_ID/images/MY_IMAGE:latest
docker tag MY_IMAGE:latest asia-south1-docker.pkg.dev/PROJECT_ID/images/MY_IMAGE:$GIT_TAG
docker push asia-south1-docker.pkg.dev/PROJECT_ID/images/MY_IMAGE:latest
docker push asia-south1-docker.pkg.dev/PROJECT_ID/images/MY_IMAGE:$GIT_TAG
I also added the Artifact Registry Write principal to repository with service email.Every other step execute successfully except last one. How can I fix it?
Nikhil Kumar
there are two possibilities for this one you might have not provided sufficient permissions but that’s not true in this case so ruling it out the second case is that the details you are passing in the pipelines might not be correct for example some human errors while entering project ID and image name, from the pipeline code I can see that you are passing these details through variables so if that’s the case you should be using $ symbol before the variable for it’s value to get reflected in the pipeline. Example: projectid = 1234 you should be using $projectid in the link – Fullfaceddocker tag MY_IMAGE:latest gcr.io/PROJECT_ID/MY_IMAGE:latest
docker tag MY_IMAGE:latest gcr.io/PROJECT_ID/MY_IMAGE:$GIT_TAG
docker push gcr.io/PROJECT_ID/MY_IMAGE:latest
docker push gcr.io/PROJECT_ID/MY_IMAGE:$GIT_TAG
and it worked – Kaltman