skip to Main Content

I am running the google-github-actions/deploy-cloudrun Action on Github, which fails when trying to push a docker image to Artifact Registry.

  1. I authenticate through an identity pool
  2. The docker image builds successfully
  3. However, pushing the image to 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

  • Artifact Registry Administrator
  • Cloud Run Admin
  • Service Account User

I am out of ideas why to the authenticated docker it appears that the registry doesn’t exist.

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. 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 }}"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search