Reputation: 596
I am trying to put repo creation in Github Action for CI/CD.
However, I have found that I cannot repeat the following creation command.
gcloud artifacts repositories create my-repo
If I do this when there already is a repo, the operation will simply fail.
Is there a good way to execute create only if there isn't such repo?
Upvotes: 2
Views: 1771
Reputation: 1328292
If you don't have too many repositories, I would:
set a variable with the result of (listing repositories)
gcloud artifacts repositories list|grep my-repo
Or: more scalable, set the variable with the result of gcloud artifacts repositories describe
gcloud artifacts repositories describe my-repo --location=us-west1
See a concrete (GitHub workflow) example here.
Upvotes: 1