Skip to content

Commit f559cce

Browse files
committed
update GitHub Actions Workflows
1 parent 7633ef0 commit f559cce

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/deployment.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jobs:
6767
image: us-central1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/cloud-run/cloud-run-back:${{ env.IMAGE_VERSION }}
6868
region: us-central1
6969
project_id: ${{ secrets.PROJECT_ID }}
70+
env_vars: |-
71+
PORT=4000
7072
7173
- name: Deploy to Cloud Run Frontend
7274
id: deploy-cloud-run-front
@@ -76,8 +78,10 @@ jobs:
7678
image: us-central1-docker.pkg.dev/${{ secrets.PROJECT_ID }}/cloud-run/cloud-run-front:${{ env.IMAGE_VERSION }}
7779
region: us-central1
7880
project_id: ${{ secrets.PROJECT_ID }}
81+
env_vars: |-
82+
PORT=80
7983
80-
- name: 'Use output'
84+
- name: Test Cloud Run
8185
run: |
8286
'curl "${{ steps.deploy-cloud-run-back.outputs.url }}"'
8387
'curl "${{ steps.deploy-cloud-run-front.outputs.url }}"'

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,53 @@ minimalistic typescript web app
66
- `docker-compose build` build app
77
- http://localhost front-end entry
88
- 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

Comments
 (0)