Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
217 commits
Select commit Hold shift + click to select a range
88346ff
Setting up GitHub Classroom Feedback
github-classroom[bot] Sep 1, 2022
43153f7
add gitignore
bobbylaw Sep 7, 2022
0344df5
add error-handling middleware, function to check for duplicate userna…
bobbylaw Sep 8, 2022
d1f9405
add login route to return jwt
bobbylaw Sep 8, 2022
f589b9a
add authentication middleware, hash and salt password and blacklist t…
bobbylaw Sep 8, 2022
4ab9e40
add bcrypt
bobbylaw Sep 8, 2022
74e4ea8
Implement backend matching service with difficulty levels
chewwh09 Sep 10, 2022
2464cbb
update: login, signup page
andrea-twl Sep 10, 2022
92ae653
add: navbar
andrea-twl Sep 10, 2022
e814587
add: homepage
andrea-twl Sep 11, 2022
0b19541
add: timer page
andrea-twl Sep 11, 2022
ecd6f91
Merge pull request #2 from CS3219-AY2223S1/add-mvp-frontend
andrea-twl Sep 11, 2022
4da5627
check for invalid token
bobbylaw Sep 11, 2022
b046863
add delete user api
bobbylaw Sep 11, 2022
47c7597
add update password api
bobbylaw Sep 11, 2022
a3adb24
update post to get
bobbylaw Sep 11, 2022
177b73f
move hashing to mongoose
bobbylaw Sep 11, 2022
766935a
fix issue
bobbylaw Sep 12, 2022
8b06e94
Add package-lock.json file
chewwh09 Sep 13, 2022
07c0666
Merge branch 'main' into matching-service
chewwh09 Sep 13, 2022
a8808c0
Integrate match service frontend to backend
chewwh09 Sep 13, 2022
f5af981
Merge pull request #3 from CS3219-AY2223S1/user-service
bobbylaw Sep 13, 2022
1fe0db7
Merge pull request #4 from CS3219-AY2223S1/matching-service
bobbylaw Sep 13, 2022
891316f
Extract constants to a file
chewwh09 Sep 13, 2022
7251ed9
add: preliminary functions and password dialog
andrea-twl Sep 14, 2022
49c7e9d
update: delete, update
andrea-twl Sep 15, 2022
33e685e
add: signup shortcut
andrea-twl Sep 15, 2022
6f3ce37
add: username to matching page
andrea-twl Sep 15, 2022
d12b300
fix: logout
andrea-twl Sep 24, 2022
5dedb7b
add: username in room page
andrea-twl Sep 24, 2022
5e988ae
add: localstorage auth
andrea-twl Sep 24, 2022
6b91197
Merge pull request #6 from CS3219-AY2223S1/connect-user-service
bobbylaw Sep 25, 2022
3fdf047
skeleton for question service with question model
bobbylaw Sep 25, 2022
3e1117e
Write code template on how collaboration should works
chewwh09 Oct 6, 2022
7c199e0
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
chewwh09 Oct 6, 2022
9255b85
add: code editor ugly
andrea-twl Oct 6, 2022
4ae76c0
add route to fetch question model
bobbylaw Oct 7, 2022
d649374
Add try catch block
chewwh09 Oct 7, 2022
2ad11b1
Merge branch 'question-service' into collaboration-service
chewwh09 Oct 7, 2022
53c9d62
Connect collaboration service to question service
chewwh09 Oct 7, 2022
74ed2b9
Merge branch 'room-page-mvp' into collaboration-service
chewwh09 Oct 7, 2022
77f24f1
add path to fetch leetcode question
bobbylaw Oct 7, 2022
0a9741e
Connect frontend with collaboration service
chewwh09 Oct 7, 2022
b276adf
Merge pull request #8 from CS3219-AY2223S1/question-service
chewwh09 Oct 7, 2022
794fe29
Merge pull request #7 from CS3219-AY2223S1/room-page-mvp
chewwh09 Oct 7, 2022
27b8168
Merge branch 'main' into collaboration-service
chewwh09 Oct 7, 2022
6ab3cdd
Merge pull request #9 from CS3219-AY2223S1/collaboration-service
andrea-twl Oct 7, 2022
1d3def6
Add TTL to the collaboration model
chewwh09 Oct 8, 2022
031b882
Format question display to html tags
chewwh09 Oct 10, 2022
8faee7d
update: protect routes
andrea-twl Oct 10, 2022
a9d0ed7
update: cookie storage instead of local storage
andrea-twl Oct 10, 2022
d138573
Merge pull request #10 from CS3219-AY2223S1/protect-routes
bobbylaw Oct 11, 2022
2d3e37f
add requirements.txt for python script
bobbylaw Oct 11, 2022
7271640
Change difficulty naming to uppercase
chewwh09 Oct 11, 2022
bd1fe89
add verifyToken api
bobbylaw Oct 11, 2022
5f4b19c
add controller for new api
bobbylaw Oct 11, 2022
7597ca6
remove authentication from user-service
bobbylaw Oct 11, 2022
5bebdc4
add api gateway with auth
bobbylaw Oct 11, 2022
bb73081
Create context on frontend and connect matching page to room page
chewwh09 Oct 11, 2022
e8ca09f
Debug issues on collaboration service
chewwh09 Oct 11, 2022
5646213
Merge branch 'main' into collaboration-service
chewwh09 Oct 11, 2022
b081015
refactor api path
bobbylaw Oct 13, 2022
043c2dd
clean up user-service
bobbylaw Oct 13, 2022
2706b1c
clean up question-service
bobbylaw Oct 13, 2022
44e90e0
Merge pull request #11 from CS3219-AY2223S1/collaboration-service
andrea-twl Oct 14, 2022
0a3c862
Merge branch 'main' into api-gateway
chewwh09 Oct 14, 2022
82ea453
Create api gateway for matching-service
chewwh09 Oct 14, 2022
a16aa7c
Change file name
chewwh09 Oct 14, 2022
05d9fbc
Create api gateway for question and collaboration service
chewwh09 Oct 14, 2022
69e39a0
save dependency
bobbylaw Oct 14, 2022
762e419
remove package that is installed wrongly
bobbylaw Oct 14, 2022
d37ab82
Merge branch 'api-gateway' of https://github.com/CS3219-AY2223S1/cs32…
chewwh09 Oct 14, 2022
51aae6d
Connect frontend to API gateway
chewwh09 Oct 14, 2022
4ab3a85
dockerise backend and clean up backend
bobbylaw Oct 15, 2022
48ae550
remove log
bobbylaw Oct 15, 2022
f1bce98
Fix timeout bug
chewwh09 Oct 15, 2022
8a3d012
Extract api calls to another folder
chewwh09 Oct 15, 2022
ba04ffa
Merge pull request #12 from CS3219-AY2223S1/api-gateway
chewwh09 Oct 17, 2022
32827cc
Remove unnecessary parameters
chewwh09 Oct 17, 2022
b860232
Refactor socket events
chewwh09 Oct 17, 2022
7ef8409
Add leave room event in socket
chewwh09 Oct 17, 2022
e98be49
clean up question database
bobbylaw Oct 21, 2022
054f008
set up history-service
bobbylaw Oct 21, 2022
5407d13
Add find collaborations api call for history service
chewwh09 Oct 24, 2022
407cb6f
Refactor api gateway socket methods
chewwh09 Oct 24, 2022
e8ba5b3
Move socket context into room context
chewwh09 Oct 24, 2022
936f995
add model and routes
bobbylaw Oct 25, 2022
3b73ddd
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Oct 25, 2022
9214548
Add video communication
chewwh09 Oct 25, 2022
0a0de95
add frontend and history to docker
bobbylaw Oct 25, 2022
87078e5
Merge branch 'communication-service' of https://github.com/CS3219-AY2…
bobbylaw Oct 25, 2022
729587a
fix bug
bobbylaw Oct 25, 2022
89a4b91
Create adding of user's entered room history from api gateway to hist…
chewwh09 Oct 26, 2022
561341a
fix bug
bobbylaw Oct 26, 2022
ca480ae
add history to api gateway
bobbylaw Oct 26, 2022
73ab708
add collab route in api gateway to get room information
bobbylaw Oct 26, 2022
b390475
Change multiple room id to single room id for get collab api
chewwh09 Oct 26, 2022
2219dc7
Connect socket with history service microservice
chewwh09 Oct 26, 2022
0227383
add skeleton test for user-service
bobbylaw Oct 27, 2022
4216caa
Create user-service-ci-cd.yml
bobbylaw Oct 27, 2022
ee80faf
Update user-service-ci-cd.yml
bobbylaw Oct 27, 2022
a204ea1
Update user-service-ci-cd.yml
bobbylaw Oct 27, 2022
41afb77
Update user-service-ci-cd.yml
bobbylaw Oct 27, 2022
f65d76d
Update user-service-ci-cd.yml
bobbylaw Oct 27, 2022
958f07a
Merge branch 'deployment' of https://github.com/CS3219-AY2223S1/cs321…
bobbylaw Oct 27, 2022
9e3ac70
add cd
bobbylaw Oct 28, 2022
f2f6332
Update user-service-ci-cd.yml
bobbylaw Oct 28, 2022
cba00a5
Update user-service-ci-cd.yml
bobbylaw Oct 28, 2022
aab08fe
Update user-service-ci-cd.yml
bobbylaw Oct 28, 2022
2a00f67
Update user-service-ci-cd.yml
bobbylaw Oct 28, 2022
4f38edb
Merge branch 'history-service' of https://github.com/CS3219-AY2223S1/…
bobbylaw Oct 28, 2022
bde86cf
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Oct 28, 2022
ace2ff5
add unit test
bobbylaw Oct 28, 2022
9218d84
Create matching-service-ci-cd.yml
bobbylaw Oct 28, 2022
a3cb574
Create question-service-ci-cd.yml
bobbylaw Oct 28, 2022
62f2d13
Create collaboration-service-ci-cd.yml
bobbylaw Oct 28, 2022
eb5e353
Create history-service-ci-cd.yml
bobbylaw Oct 28, 2022
f4c7bbf
Update history-service-ci-cd.yml
bobbylaw Oct 28, 2022
9eab306
Create api-gateway-ci-cd.yml
bobbylaw Oct 28, 2022
0a744b7
Update user-service-ci-cd.yml
bobbylaw Oct 28, 2022
84fb05a
add: scss files and typography
andrea-twl Nov 2, 2022
f518854
Move Room contexts into context folder
chewwh09 Nov 3, 2022
86a957a
Change useNavigate to condition rendering
chewwh09 Nov 3, 2022
d550c6d
Remove magic numbers
chewwh09 Nov 3, 2022
3ae5fb9
Move page context into room context
chewwh09 Nov 3, 2022
ab9d637
Refine code quality
chewwh09 Nov 3, 2022
c4ab70d
add: text atoms
andrea-twl Nov 3, 2022
a41fb89
add: globa variables
andrea-twl Nov 3, 2022
171c6bb
add: buttons, turn off auth for now
andrea-twl Nov 3, 2022
15fe6c9
add: home page
andrea-twl Nov 3, 2022
4c3b8f0
add: login card
andrea-twl Nov 3, 2022
1ae3aab
refactor path
bobbylaw Nov 4, 2022
65540c5
Update api-gateway-ci-cd.yml
bobbylaw Nov 4, 2022
b22e52a
testing auto deployment
bobbylaw Nov 4, 2022
38be36b
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Nov 4, 2022
037a268
update cicd
bobbylaw Nov 4, 2022
40b712a
add cicd for frontend
bobbylaw Nov 4, 2022
6c9bfc1
update cicd
bobbylaw Nov 4, 2022
5c7ce05
update frontend cicd
bobbylaw Nov 4, 2022
983ad70
fix env
bobbylaw Nov 4, 2022
88d2d69
fix bugs
bobbylaw Nov 4, 2022
9072444
update env name
bobbylaw Nov 4, 2022
8bdf82d
update: fancy username field behaviour
andrea-twl Nov 5, 2022
44ca63d
Authenticate sockets
chewwh09 Nov 5, 2022
450c091
Fix unauthenticated socket connection
chewwh09 Nov 5, 2022
ef17393
update: fancy passwor dbehavoiur
andrea-twl Nov 5, 2022
d83a401
add: authcard functions
andrea-twl Nov 5, 2022
f2434e7
add: sign up page
andrea-twl Nov 5, 2022
d1ce6f4
add: fancy button
andrea-twl Nov 5, 2022
7852214
add nginx to serve production frontend
bobbylaw Nov 5, 2022
34e2109
Update frontend-ci-cd.yml
bobbylaw Nov 5, 2022
ea3c9a8
fix bug
bobbylaw Nov 5, 2022
f5b85bf
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Nov 5, 2022
0e5b5ab
Update frontend-ci-cd.yml
bobbylaw Nov 5, 2022
11740c0
test
bobbylaw Nov 5, 2022
be6073f
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Nov 5, 2022
5d6b606
Update frontend-ci-cd.yml
bobbylaw Nov 5, 2022
99940df
Update frontend-ci-cd.yml
bobbylaw Nov 5, 2022
7fc249f
fix bug
bobbylaw Nov 5, 2022
5bfd19d
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Nov 5, 2022
539a225
fix naming
bobbylaw Nov 5, 2022
49a591a
fix: button timing
andrea-twl Nov 6, 2022
2072b78
Change naming in API path
chewwh09 Nov 6, 2022
f6caa07
unmute webcam
chewwh09 Nov 6, 2022
be0ad6f
Extract constants
chewwh09 Nov 6, 2022
ecd9a5d
Extract more constants
chewwh09 Nov 6, 2022
54c4bed
Revert version
chewwh09 Nov 6, 2022
4646136
Change of constants
chewwh09 Nov 6, 2022
dc236e6
update: file for easier merging
andrea-twl Nov 7, 2022
99ed429
fix conflicts
andrea-twl Nov 7, 2022
4a60678
update: reroute
andrea-twl Nov 7, 2022
d690176
add: navbar styling
andrea-twl Nov 7, 2022
0c25b19
fix: click events
andrea-twl Nov 7, 2022
b59420d
add: navbar functionality
andrea-twl Nov 7, 2022
25a7925
add: match card
andrea-twl Nov 8, 2022
30b3d1a
utter chaos
andrea-twl Nov 8, 2022
a834ec0
fix: matching
andrea-twl Nov 8, 2022
5c87ecf
fix: card flex
andrea-twl Nov 8, 2022
fd7c1dc
add: room page header
andrea-twl Nov 8, 2022
602556d
update: room page (wip)
andrea-twl Nov 8, 2022
3d74e5a
fix: history
andrea-twl Nov 8, 2022
72aaf31
add room difficulty
bobbylaw Nov 8, 2022
4c9d5ec
fix: room page
andrea-twl Nov 8, 2022
b31188e
update: scroll
andrea-twl Nov 8, 2022
d898f15
fix: slipups
andrea-twl Nov 8, 2022
802fff1
fix: leave room
andrea-twl Nov 8, 2022
2a06de1
fixes
andrea-twl Nov 8, 2022
c60bbff
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
andrea-twl Nov 8, 2022
0ebebf4
add: configs, fixed stuff
andrea-twl Nov 8, 2022
7a94ecd
fix: alignment
andrea-twl Nov 8, 2022
4a793d1
fix some bugs
bobbylaw Nov 8, 2022
5f2facd
add: prelim history list
andrea-twl Nov 8, 2022
0b59b78
add socket disconnect on logout
bobbylaw Nov 8, 2022
1749100
update: repsonive
andrea-twl Nov 8, 2022
1872102
Merge branch 'fancy-ui-2' of https://github.com/CS3219-AY2223S1/cs321…
andrea-twl Nov 8, 2022
3073a91
add: opening list
andrea-twl Nov 8, 2022
7bb64a4
finish history list
andrea-twl Nov 8, 2022
10d891a
add: further styling
andrea-twl Nov 8, 2022
a2c8701
add: donut
andrea-twl Nov 8, 2022
85a55c4
fix
andrea-twl Nov 8, 2022
f1fb54e
fix:matching page
andrea-twl Nov 8, 2022
670cdcb
fix: sign up
andrea-twl Nov 8, 2022
3de6c63
Merge pull request #16 from CS3219-AY2223S1/fancy-ui-3
chewwh09 Nov 8, 2022
65abeae
Mute personal webcam
chewwh09 Nov 8, 2022
090d28a
fix bugs
bobbylaw Nov 8, 2022
41b8cfd
Close stream when peer leave
chewwh09 Nov 8, 2022
8426d15
fixes
andrea-twl Nov 9, 2022
833e998
add: null attempt
andrea-twl Nov 9, 2022
82489c2
delete: console log
andrea-twl Nov 9, 2022
be6cdc0
add: clean inputs
andrea-twl Nov 9, 2022
a381965
adjust responive
andrea-twl Nov 9, 2022
9a132c0
Update README.md
bobbylaw Nov 9, 2022
8af3cc0
fixes
andrea-twl Nov 9, 2022
980268a
Merge pull request #17 from CS3219-AY2223S1/fancy-ui-4
bobbylaw Nov 9, 2022
95884b7
add sample .env file
bobbylaw Nov 9, 2022
0f9fcb8
Merge branch 'main' of https://github.com/CS3219-AY2223S1/cs3219-proj…
bobbylaw Nov 9, 2022
ea8108d
fix config
bobbylaw Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
USER_SERVICE_URL=http://user-service:8000
MATCHING_SERVICE_URL=http://matching-service:8001
QUESTION_SERVICE_URL=http://question-service:8002
COLLABORATION_SERVICE_URL=http://collaboration-service:8003
HISTORY_SERVICE_URL=http://history-service:8004
DB_CLOUD_URI=
DB_LOCAL_URI=mongodb://mongo_db:27017/cs3219_project
ENV=DEV
SECRET_TOKEN=<Your Token>
TOKEN_EXPIRY=10800s
91 changes: 91 additions & 0 deletions .github/workflows/api-gateway-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: api-gateway-ci-cd

on:
workflow_dispatch:
push:
paths:
- api-gateway/**
branches: [ "main" ]
pull_request:
paths:
- api-gateway/**
branches: [ "main" ]

env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
SERVICE: api-gateway
REGION: asia-southeast1
PORT: 8010

defaults:
run:
working-directory: ./api-gateway

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
mongodb-version: ['6.0']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./api-gateway/package-lock.json

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}

- run: npm ci
- run: npm run build --if-present
- run: npm test
deploy:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'

steps:
- name: Checkout
uses: actions/checkout@v3

#Alternative option - authentication via credentials json
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Authorize Docker push
run: gcloud auth configure-docker

- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--region ${{ env.REGION }} \
--port ${{ env.PORT }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} \
--platform "managed" \
--quiet
91 changes: 91 additions & 0 deletions .github/workflows/collaboration-service-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: collaboration-service-ci-cd

on:
workflow_dispatch:
push:
paths:
- collaboration-service/**
branches: [ "main" ]
pull_request:
paths:
- collaboration-service/**
branches: [ "main" ]

env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
SERVICE: collaboration-service
REGION: asia-southeast1
PORT: 8003

defaults:
run:
working-directory: ./collaboration-service

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
mongodb-version: ['6.0']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./collaboration-service/package-lock.json

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}

- run: npm ci
- run: npm run build --if-present
- run: npm test
deploy:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'

steps:
- name: Checkout
uses: actions/checkout@v3

#Alternative option - authentication via credentials json
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Authorize Docker push
run: gcloud auth configure-docker

- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--region ${{ env.REGION }} \
--port ${{ env.PORT }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} \
--platform "managed" \
--quiet
84 changes: 84 additions & 0 deletions .github/workflows/frontend-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: frontend-ci-cd

on:
workflow_dispatch:
push:
paths:
- frontend/**
branches: [ "main" ]
pull_request:
paths:
- frontend/**
branches: [ "main" ]

env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
SERVICE: frontend
REGION: asia-southeast1
PORT: 80

defaults:
run:
working-directory: ./frontend

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./api-gateway/package-lock.json

- run: npm ci
- run: npm run lint
deploy:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'

steps:
- name: Checkout
uses: actions/checkout@v3

#Alternative option - authentication via credentials json
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Authorize Docker push
run: gcloud auth configure-docker

- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} --build-arg REACT_APP_API_GATEWAY_URL=https://api-gateway-hywbpmheia-as.a.run.app .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--region ${{ env.REGION }} \
--port ${{ env.PORT }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} \
--platform "managed" \
--quiet
91 changes: 91 additions & 0 deletions .github/workflows/history-service-ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: history-service-ci-cd

on:
workflow_dispatch:
push:
paths:
- history-service/**
branches: [ "main" ]
pull_request:
paths:
- history-service/**
branches: [ "main" ]

env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
SERVICE: history-service
REGION: asia-southeast1
PORT: 8004

defaults:
run:
working-directory: ./history-service

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
mongodb-version: ['6.0']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: ./history-service/package-lock.json

- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}

- run: npm ci
- run: npm run build --if-present
- run: npm test
deploy:
needs: build
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'

steps:
- name: Checkout
uses: actions/checkout@v3

#Alternative option - authentication via credentials json
- id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

# Setup gcloud CLI
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0

- name: Authorize Docker push
run: gcloud auth configure-docker

- name: Build and Push Container
run: |-
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--region ${{ env.REGION }} \
--port ${{ env.PORT }} \
--image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{ github.sha }} \
--platform "managed" \
--quiet
Loading