Skip to content

Latest commit

 

History

History
executable file
·
41 lines (32 loc) · 1.26 KB

deploy-cloud-build.md

File metadata and controls

executable file
·
41 lines (32 loc) · 1.26 KB

Deploy to Cloud Build

This document describes how to use GCR Cleaner in Cloud Build with Artifact Registry

  1. Grant a role roles/artifactregistry.repoAdmin to the Cloud Build service account because it need artifactregistry.repositories.deleteArtifacts permission.

  2. Export your project ID as an environment variable.

    export PROJECT_ID="my-project"
  3. Create a YAML file named cloudbuild.yaml which will always keep three images:

    steps:
      - name: asia-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli:latest
        args:
          - -repo
          - "asia-docker.pkg.dev/my-project/my-repo/my-image"
          - -keep
          - "3"
          - -tag-filter-any
          - ".*"
  4. Manual trigger Cloud Build using gcloud CLI to check it:

    gcloud builds submit \
      --project "${PROJECT_ID}" \
      --config cloudbuild.yaml .