-
Notifications
You must be signed in to change notification settings - Fork 2
75 lines (63 loc) · 3.13 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Deploy To Production
on:
push:
branches:
- production
env:
SHA: $(git rev-parse HEAD)
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Docker
run: |-
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Set Service Key
uses: 'google-github-actions/auth@v0'
with:
credentials_json: '${{ secrets.GKE_SA_KEY }}'
- name: Set Project
uses: google-github-actions/setup-gcloud@v0
with:
project_id: cs3219-365909 # from google cloud console
- name: Auth
run: |-
gcloud --quiet auth configure-docker
- name: Get Credentials
uses: google-github-actions/get-gke-credentials@v0
with:
cluster_name: cs3219-cluster
location: asia-southeast1-a
- name: Build new Docker image
run: |-
docker build -t b9jmthkk/frontend:latest -t b9jmthkk/frontend:${{ env.SHA }} -f ./frontend/Dockerfile.production ./frontend
docker build -t b9jmthkk/user:latest -t b9jmthkk/user:${{ env.SHA }} -f ./user-service/Dockerfile ./user-service
docker build -t b9jmthkk/question:latest -t b9jmthkk/question:${{ env.SHA }} -f ./question-service/Dockerfile ./question-service
docker build -t b9jmthkk/matching:latest -t b9jmthkk/matching:${{ env.SHA }} -f ./matching-service/Dockerfile ./matching-service
docker build -t b9jmthkk/room:latest -t b9jmthkk/room:${{ env.SHA }} -f ./room-service/Dockerfile ./room-service
docker build -t b9jmthkk/history:latest -t b9jmthkk/history:${{ env.SHA }} -f ./history-service/Dockerfile ./history-service
- name: Push to Docker Hub
run: |-
docker push b9jmthkk/frontend:latest
docker push b9jmthkk/user:latest
docker push b9jmthkk/question:latest
docker push b9jmthkk/matching:latest
docker push b9jmthkk/room:latest
docker push b9jmthkk/history:latest
docker push b9jmthkk/frontend:${{ env.SHA }}
docker push b9jmthkk/user:${{ env.SHA }}
docker push b9jmthkk/question:${{ env.SHA }}
docker push b9jmthkk/matching:${{ env.SHA }}
docker push b9jmthkk/room:${{ env.SHA }}
docker push b9jmthkk/history:${{ env.SHA }}
- name: Re-Apply K8s Config and update image
run: |-
kubectl apply -f k8s/manifests
kubectl set image deployments/frontend-deployment frontend=b9jmthkk/frontend:${{ env.SHA }}
kubectl set image deployments/user-deployment user=b9jmthkk/user:${{ env.SHA }}
kubectl set image deployments/question-deployment question=b9jmthkk/question:${{ env.SHA }}
kubectl set image deployments/matching-deployment matching=b9jmthkk/matching:${{ env.SHA }}
kubectl set image deployments/room-deployment room=b9jmthkk/room:${{ env.SHA }}
kubectl set image deployments/history-deployment history=b9jmthkk/history:${{ env.SHA }}