dockergithubgithub-actionsdocker-push

Github action error during push docker image


I am trying to run within my github action a docker push since like to use the same image as part of different repos. The code I am using is the following:

  docker build . --pull --rm --file "$GITHUB_WORKSPACE/${{ matrix.path }}/Dockerfile" --tag ${{ matrix.name }}
  echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

  IMAGE_ID=ghcr.io/${{ github.repository }}/${{ matrix.name }}
  # Strip git ref prefix from version
  VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
  echo IMAGE_ID=$IMAGE_ID
  echo VERSION=$VERSION
  docker tag ${{ matrix.name }} $IMAGE_ID:$VERSION
  docker push $IMAGE_ID:$VERSION

The error I am getting is related to permissions:

  denied: installation not allowed to Create organization package"

Any suggestion what is missing from my permissions.


Solution

  • thanks all for your hints it was a combination of the missing PAT rules and the wrong format. The following code works now:

          docker build . --pull --rm --file "$GITHUB_WORKSPACE/${{ matrix.path }}/Dockerfile" --tag ${{ matrix.name }}
          echo "${{ secrets.GIT_DOCKER_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
    
          IMAGE_ID=ghcr.io/${{ github.actor }}/${{ matrix.name }}
          # Change all uppercase to lowercase
          IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
          # Strip git ref prefix from version
          VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
          echo IMAGE_ID=$IMAGE_ID
          echo VERSION=$VERSION
          docker tag ${{ matrix.name }} $IMAGE_ID:$VERSION
          docker push $IMAGE_ID:$VERSION
    

    The PAT has the following permissions:

    enter image description here