Reputation: 4066
I am running the google-github-actions/deploy-cloudrun Action on Github, which fails when trying to push a docker image to Artifact Registry.
Google Artifact Registry
fails with name invalid: Missing image name. Pushes should be of the form docker push HOST-NAME/PROJECT-ID/REPOSITORY/IMAGE
Github action YML
# Authenticate Docker to Google Cloud Artifact Registry
- name: Docker Auth
id: docker-auth
uses: 'docker/login-action@v1'
with:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ env.GAR_LOCATION }}-docker.pkg.dev'
- name: Build and Push Container
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}" .
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}"
Log output
Successfully built 2edd636b95c7
Successfully tagged us-central1-docker.pkg.dev/[my-project]/github-actions:ecb28fdf92addae09fe6bd9e86033027b2850de3
The push refers to repository [us-central1-docker.pkg.dev/[my-project]/github-actions]
8189f048f482: Retrying in 5 seconds
... multiple retries ...
name invalid: Missing image name. Pushes should be of the form docker push HOST-NAME/PROJECT-ID/REPOSITORY/IMAGE
Error: Process completed with exit code 1.
I do have Artifact Registry enabled, and created repository with the path us-central1-docker.pkg.dev/[my-project]/github-actions
The IAM role has following permissions
I am out of ideas why to the authenticated docker it appears that the registry doesn't exist.
Upvotes: 11
Views: 5474
Reputation: 1
Just ran into this same issue. When creating a repository in Artifact Registry, the "repository" will contain many different images instead of being a repository for a single image with different tags.
If you want to match the naming scheme to your GitHub repository, you can use the following as your Docker image name:
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ github.repository }}:${{ github.sha }}" .
Upvotes: 0
Reputation: 103
I was struggling with the same issue.
Adding to the answer above, instead of hardcoding "/website", I changed the original script to add the name as a variable:
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.SERVICE }}:${{ github.sha }}"
Upvotes: 10
Reputation: 4066
Turns out, the above notation is only specifying HOST-NAME/PROJECT-ID/REPOSITORY:tag
but not /IMAGE
Replacing all occurrences by e.g. ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/website:${{ github.sha }}
will use /website
as the actual image name within the repository.
Upvotes: 16