GoogleCloudPlatform / gcr-cleaner

Delete untagged image refs in Google Container Registry or Artifact Registry
Apache License 2.0
805 stars 112 forks source link

Usage question #131

Closed hassanshaikley closed 1 year ago

hassanshaikley commented 1 year ago
    steps:
      - id: "auth"
        name: Login to GCR
        uses: docker/login-action@v1
        ....

      - uses: "docker://us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli"
        with:
          args: >-
            -repo=gcr.io/place/my-image-name

ENIED: Failed to read tags for host 'gcr.io', repository

I've tried -repo=gcr.io/place/my-image-name:latest and that didn't work

Why is this happening? Any help is appreciated.

hassanshaikley commented 1 year ago

I needed the extra auth step

ralphotowo commented 1 year ago

@hassanshaikley Can you provide clarity on what you mean by "the extra auth step"?

I have configured GitHub Actions as follows and I also encounter the same error message:

failed to list tags for repo gcr.io/webapp-alpha/curl: GET https://gcr.io/v2/project-alpha/curl/tags/list?n=1000: DENIED: Failed to read tags for host 'gcr.io', repository '/v2/project-alpha/curl/tags/list?n=1000'

Here's my action code:

name: 'gcr-cleaner'

on:
  schedule:
    - cron: '0 0 */1 * *'
  push:
  workflow_dispatch:

jobs:
  gcr-cleaner:
    runs-on: ubuntu-latest
    steps:
      - name: Login to gcr.io
        uses: docker/login-action@v2
        with:
          registry: gcr.io
          username: _json_key
          password: ${{ secrets.GCR_CLEANER_SERVICE_ACCOUNT }}

      - name: Purge untagged images
        uses: 'docker://us-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli'
        env:
          GCRCLEANER_LOG: debug
        with:
          args: >-
            -repo=gcr.io/project-alpha/curl
            -grace=168h
            -keep=10 
            -dry-run