@@ -6,3 +6,53 @@ minimalistic typescript web app
6
6
- ` docker-compose build ` build app
7
7
- http://localhost front-end entry
8
8
- http://localhost:4000 back-end api endpoint
9
+
10
+ ## Setup GitHub Actions (Secrets and IAM Google Cloud)
11
+ - Create a new service account in Google Cloud IAM
12
+
13
+ ``` bash
14
+ export PROJECT_ID=" your-project-id"
15
+
16
+ gcloud iam service-accounts create \
17
+ " cloud-run-sa" \
18
+ --project=" ${PROJECT_ID} " \
19
+ --description=" Cloud Run Service Account" \
20
+ --display-name=" Cloud Run Service Account"
21
+
22
+ gcloud projects add-iam-policy-binding " ${PROJECT_ID} " \
23
+ --member=" serviceAccount:cloud-run-sa@${PROJECT_ID} .iam.gserviceaccount.com" \
24
+ --role=" roles/artifactregistry.repoAdmin,roles/run.developer"
25
+ ```
26
+
27
+ - Create a new Workload Identity Pool
28
+
29
+ ``` bash
30
+ gcloud iam workload-identity-pools create " github" \
31
+ --project=" ${PROJECT_ID} " \
32
+ --location=" global" \
33
+ --display-name=" GitHub Actions Pool"
34
+
35
+ gcloud iam workload-identity-pools describe " github" \
36
+ --project=" ${PROJECT_ID} " \
37
+ --location=" global" \
38
+ --format=" value(name)"
39
+
40
+ gcloud iam workload-identity-pools providers create-oidc " github-repo-provider" \
41
+ --project=" ${PROJECT_ID} " \
42
+ --location=" global" \
43
+ --workload-identity-pool=" github" \
44
+ --display-name=" My GitHub repo Provider" \
45
+ --attribute-mapping=" google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.repository=assertion.repository,attribute.repository_owner=assertion.repository_owner,attribute.repository_id=assertion.repository_id" \
46
+ --issuer-uri=" https://token.actions.githubusercontent.com"
47
+
48
+ export SA_EMAIL=" cloud-run-sa@${PROJECT_ID} .iam.gserviceaccount.com"
49
+ export WORKLOAD_POOL=` gcloud iam workload-identity-pools describe " github" \
50
+ --project=" ${PROJECT_ID} " \
51
+ --location=" global" \
52
+ --format=" value(name)" `
53
+
54
+ gcloud iam service-accounts add-iam-policy-binding ${SA_EMAIL} \
55
+ --project=" ${PROJECT_ID} " \
56
+ --role=" roles/iam.workloadIdentityUser" \
57
+ --member=" principalSet://iam.googleapis.com/${WORKLOAD_POOL} /attribute.repository/${REPO_OWNER} /${REPO_NAME} "
58
+ ```
0 commit comments