-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Added]add-gcp-cloudbuild-instruction (#135)
Hi I write some instrction about how to use gcr-cleaner in GCP cloudbuild. I think it may be necessary. Because I spend some time to try how to use and README.md doesn't have instrction about it
- Loading branch information
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Deploy GCR Cleaner to Cloudbuild | ||
|
||
This document describes how to use GCR Cleaner in GCP [Cloud Build][cloud-build] with [Artifact Registry][artifact-registry] | ||
|
||
1. Grant a role `roles/artifactregistry.repoAdmin` to the [Cloud Build service account][cloud-build-service-account] | ||
because it need `artifactregistry.repositories.deleteArtifacts` permission. | ||
|
||
1. Export your project ID as an environment variable. | ||
|
||
```sh | ||
export PROJECT_ID="my-project" | ||
``` | ||
|
||
1. Create a YAML file named cloudbuild.yaml which will always keep three images: | ||
|
||
```yaml | ||
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 | ||
- ".*" | ||
``` | ||
1. Manual trigger Cloud Build using [gcloud CLI][cloud-cli] to check it: | ||
```sh | ||
gcloud builds submit \ | ||
--project "${PROJECT_ID}" \ | ||
--config cloudbuild.yaml . | ||
``` | ||
|
||
[cloud-build]: https://cloud.google.com/build | ||
[artifact-registry]: https://cloud.google.com/artifact-registry | ||
[cloud-cli]: https://cloud.google.com/cli | ||
[cloud-build-service-account]: https://cloud.google.com/build/docs/cloud-build-service-account |