Skip to content

Commit

Permalink
grant cloud build permissions to github action sa (#460)
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Leung <kleung@chainguard.dev>
  • Loading branch information
k4leung4 authored Mar 7, 2022
1 parent bba4e6b commit 4180468
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hack/github-oidc-setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ gcloud iam service-accounts add-iam-policy-binding "${SERVICE_ACCOUNT}" \
--project="${PROJECT_ID}" \
--role="roles/iam.workloadIdentityUser" \
--member="principalSet://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/${LOCATION}/workloadIdentityPools/${POOL_NAME}/attribute.repository/${REPO}"

# Adding binding is idempotent.
# Used for kicking off cloud build.
gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
--project="${PROJECT_ID}" \
--role="roles/cloudbuild.builds.editor" \
--member="serviceAccount:${SERVICE_ACCOUNT}"

# Adding binding is idempotent.
# Permission needed to run `gcloud builds`
# https://cloud.google.com/build/docs/securing-builds/configure-access-to-resources#granting_permissions_to_run_gcloud_commands
gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
--project="${PROJECT_ID}" \
--role="roles/serviceusage.serviceUsageConsumer" \
--member="serviceAccount:${SERVICE_ACCOUNT}"

0 comments on commit 4180468

Please sign in to comment.