Skip to content

Commit e1931dd

Browse files
authored
Merge pull request #115 from CS3219-AY2425S1/cloud-fix
use github actions instead of google cloud build
2 parents 7b59b97 + a2f2e3f commit e1931dd

File tree

2 files changed

+110
-16
lines changed

2 files changed

+110
-16
lines changed

.github/workflows/deploy.yml

Lines changed: 109 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
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+
137
name: Deploy to GCP
238

339
on:
@@ -6,30 +42,88 @@ on:
642
- main
743

844
jobs:
9-
deploy:
10-
permissions:
11-
contents: "read"
12-
id-token: "write"
13-
45+
check-changes:
1446
runs-on: ubuntu-latest
47+
outputs:
48+
fe: ${{ steps.filter.outputs.fe }}
49+
api: ${{ steps.filter.outputs.api }}
50+
question: ${{ steps.filter.outputs.question }}
51+
user: ${{ steps.filter.outputs.user }}
1552
steps:
1653
- uses: actions/checkout@v3
54+
- uses: dorny/paths-filter@v2
55+
id: filter
56+
with:
57+
filters: |
58+
fe:
59+
- 'peerprep-fe/**'
60+
api:
61+
- 'api-gateway/**'
62+
question:
63+
- 'question-service/**'
64+
user:
65+
- 'user-service/**'
1766
67+
deploy-fe:
68+
needs: check-changes
69+
if: ${{ needs.check-changes.outputs.fe == 'true' }}
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v3
1873
- id: "auth"
19-
name: "Authenticate to Google Cloud"
2074
uses: "google-github-actions/auth@v2"
2175
with:
2276
credentials_json: "${{ secrets.GCP_SA_KEY }}"
77+
- uses: "google-github-actions/setup-gcloud@v2"
78+
- name: "Trigger FE Cloud Build"
79+
env:
80+
NEXT_PUBLIC_API_GATEWAY_URL: ${{ secrets.NEXT_PUBLIC_API_GATEWAY_URL }}
81+
NEXT_PUBLIC_GITHUB_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_GITHUB_CLIENT_ID }}
82+
run: |
83+
gcloud builds submit --config cloudbuilds/fe.yaml \
84+
--substitutions _NEXT_PUBLIC_API_GATEWAY_URL="$NEXT_PUBLIC_API_GATEWAY_URL",_NEXT_PUBLIC_GITHUB_CLIENT_ID="$NEXT_PUBLIC_GITHUB_CLIENT_ID"
2385
24-
- name: "Set up Cloud SDK"
25-
uses: "google-github-actions/setup-gcloud@v2"
86+
deploy-api-gateway:
87+
needs: check-changes
88+
if: ${{ needs.check-changes.outputs.api == 'true' }}
89+
runs-on: ubuntu-latest
90+
steps:
91+
- uses: actions/checkout@v3
92+
- id: "auth"
93+
uses: "google-github-actions/auth@v2"
94+
with:
95+
credentials_json: "${{ secrets.GCP_SA_KEY }}"
96+
- uses: "google-github-actions/setup-gcloud@v2"
97+
- name: "Trigger API Gateway Cloud Build"
98+
run: |
99+
gcloud builds submit --config cloudbuilds/api-gateway.yaml
26100
27-
- name: "Use gcloud CLI"
28-
run: "gcloud info"
101+
deploy-question-svc:
102+
needs: check-changes
103+
if: ${{ needs.check-changes.outputs.question == 'true' }}
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v3
107+
- id: "auth"
108+
uses: "google-github-actions/auth@v2"
109+
with:
110+
credentials_json: "${{ secrets.GCP_SA_KEY }}"
111+
- uses: "google-github-actions/setup-gcloud@v2"
112+
- name: "Trigger Question Service Cloud Build"
113+
run: |
114+
gcloud builds submit --config cloudbuilds/question-service.yaml
29115
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 }}
116+
deploy-user-svc:
117+
needs: check-changes
118+
if: ${{ needs.check-changes.outputs.user == 'true' }}
119+
runs-on: ubuntu-latest
120+
steps:
121+
- uses: actions/checkout@v3
122+
- id: "auth"
123+
uses: "google-github-actions/auth@v2"
124+
with:
125+
credentials_json: "${{ secrets.GCP_SA_KEY }}"
126+
- uses: "google-github-actions/setup-gcloud@v2"
127+
- name: "Trigger User Service Cloud Build"
34128
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"
129+
gcloud builds submit --config cloudbuilds/user-service.yaml

api-gateway/src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import WebSocket from 'ws';
1414
const app = express();
1515

1616
app.use(express.json());
17-
app.use(cors()); // configured so any one can use!
17+
app.use(cors()); // configured so any one can use
1818
app.options('*', cors());
1919

2020
// Logging middleware

0 commit comments

Comments
 (0)