Skip to content

Commit 8127afc

Browse files
authored
Merge pull request #116 from CS3219-AY2425S1/cloud-fix
add all types of workflows
2 parents e1931dd + 8e50f16 commit 8127afc

File tree

5 files changed

+118
-256
lines changed

5 files changed

+118
-256
lines changed

.github/workflows/deploy.yml

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
# name: Deploy to GCP
2-
3-
# on:
4-
# push:
5-
# branches:
6-
# - main
7-
8-
# jobs:
9-
# deploy:
10-
# permissions:
11-
# contents: "read"
12-
# id-token: "write"
13-
14-
# runs-on: ubuntu-latest
15-
# steps:
16-
# - uses: actions/checkout@v3
17-
18-
# - id: "auth"
19-
# name: "Authenticate to Google Cloud"
20-
# uses: "google-github-actions/auth@v2"
21-
# with:
22-
# credentials_json: "${{ secrets.GCP_SA_KEY }}"
23-
24-
# - name: "Set up Cloud SDK"
25-
# uses: "google-github-actions/setup-gcloud@v2"
26-
27-
# - name: "Use gcloud CLI"
28-
# run: "gcloud info"
29-
30-
# - name: "Trigger Cloud Build"
31-
# env: # have to use env here as cant use secrets in kubernetes for nextJS
32-
# NEXT_PUBLIC_API_GATEWAY_URL: ${{ secrets.NEXT_PUBLIC_API_GATEWAY_URL }}
33-
# NEXT_PUBLIC_GITHUB_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_GITHUB_CLIENT_ID }}
34-
# run: |
35-
# gcloud builds submit --config cloudbuild.yaml --substitutions _NEXT_PUBLIC_API_GATEWAY_URL="$NEXT_PUBLIC_API_GATEWAY_URL",_NEXT_PUBLIC_GITHUB_CLIENT_ID="$NEXT_PUBLIC_GITHUB_CLIENT_ID"
36-
371
name: Deploy to GCP
382

393
on:
@@ -63,6 +27,10 @@ jobs:
6327
- 'question-service/**'
6428
user:
6529
- 'user-service/**'
30+
matching:
31+
- 'matching-service/**'
32+
session:
33+
- 'session-service/**'
6634
6735
deploy-fe:
6836
needs: check-changes
@@ -127,3 +95,33 @@ jobs:
12795
- name: "Trigger User Service Cloud Build"
12896
run: |
12997
gcloud builds submit --config cloudbuilds/user-service.yaml
98+
99+
deploy-matching-svc:
100+
needs: check-changes
101+
if: ${{ needs.check-changes.outputs.matching == 'true' }}
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v3
105+
- id: "auth"
106+
uses: "google-github-actions/auth@v2"
107+
with:
108+
credentials_json: "${{ secrets.GCP_SA_KEY }}"
109+
- uses: "google-github-actions/setup-gcloud@v2"
110+
- name: "Trigger Matching Service Cloud Build"
111+
run: |
112+
gcloud builds submit --config cloudbuilds/matching-service.yaml
113+
114+
deploy-session-svc:
115+
needs: check-changes
116+
if: ${{ needs.check-changes.outputs.session == 'true' }}
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v3
120+
- id: "auth"
121+
uses: "google-github-actions/auth@v2"
122+
with:
123+
credentials_json: "${{ secrets.GCP_SA_KEY }}"
124+
- uses: "google-github-actions/setup-gcloud@v2"
125+
- name: "Trigger Session Service Cloud Build"
126+
run: |
127+
gcloud builds submit --config cloudbuilds/session-service.yaml

cloudbuilds/cloudbuild.yaml

Lines changed: 0 additions & 199 deletions
This file was deleted.

cloudbuilds/matching-service.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
steps:
2+
# Step 1: build and push all images to Artifact Registry
23
- name: "gcr.io/cloud-builders/docker"
34
args:
45
[
@@ -17,10 +18,28 @@ steps:
1718
"asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/matching-svc:latest",
1819
]
1920

21+
# Step 2: Clean up and deploy to GKE
22+
- name: "ubuntu"
23+
args: ["rm", "-rf", "output"]
24+
2025
- name: "gcr.io/cloud-builders/gke-deploy"
2126
args:
2227
- run
2328
- --filename=k8s/matching-service.yml
2429
- --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/matching-svc:latest
2530
- --location=asia-southeast1
2631
- --cluster=cs3219-g11-peerprep-kubes
32+
33+
# Step 3: update the deployments with the new images
34+
- name: "gcr.io/cloud-builders/kubectl"
35+
args:
36+
- "set"
37+
- "image"
38+
- "deployment/matching-svc"
39+
- "matching-svc=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/matching-svc:latest"
40+
env:
41+
- "CLOUDSDK_COMPUTE_ZONE=asia-southeast1"
42+
- "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes"
43+
44+
images:
45+
- "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/matching-svc:latest"

cloudbuilds/session-service.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
steps:
2+
# Step 1: build and push all images to Artifact Registry
3+
- name: "gcr.io/cloud-builders/docker"
4+
args:
5+
[
6+
"build",
7+
"-t",
8+
"asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/session-svc:latest",
9+
"-f",
10+
"session-service/Dockerfile",
11+
"session-service",
12+
]
13+
14+
- name: "gcr.io/cloud-builders/docker"
15+
args:
16+
[
17+
"push",
18+
"asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/session-svc:latest",
19+
]
20+
21+
# Step 2: Clean up and deploy to GKE
22+
- name: "ubuntu"
23+
args: ["rm", "-rf", "output"]
24+
25+
- name: "gcr.io/cloud-builders/gke-deploy"
26+
args:
27+
- run
28+
- --filename=k8s/session-service.yml
29+
- --image=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/session-svc:latest
30+
- --location=asia-southeast1
31+
- --cluster=cs3219-g11-peerprep-kubes
32+
33+
# Step 3: update the deployments with the new images
34+
- name: "gcr.io/cloud-builders/kubectl"
35+
args:
36+
- "set"
37+
- "image"
38+
- "deployment/session-svc"
39+
- "session-svc=asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/session-svc:latest"
40+
env:
41+
- "CLOUDSDK_COMPUTE_ZONE=asia-southeast1"
42+
- "CLOUDSDK_CONTAINER_CLUSTER=cs3219-g11-peerprep-kubes"
43+
44+
images:
45+
- "asia-southeast1-docker.pkg.dev/cs3219-g11-peerprep/cs3219-g11-repo/session-svc:latest"

0 commit comments

Comments
 (0)