-
Notifications
You must be signed in to change notification settings - Fork 5
73 lines (62 loc) · 2.24 KB
/
deploy-collab-service.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
name: Build and Deploy collab-service to GKE
on:
push:
branches:
- main
paths:
- server/collaboration-service/**
workflow_dispatch:
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: peerprep-cluster-1
GKE_ZONE: asia-southeast1
DEPLOYMENT_NAME: collab-service
REPOSITORY_NAME: peerprep
IMAGE: collaboration
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v4
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@1bee7de035d65ec5da40a31f8589e240eba8fde5
with:
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud auth configure-docker $GKE_ZONE-docker.pkg.dev --quiet
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@db150f2cc60d1716e61922b832eae71d2a45938f
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
project_id: ${{ secrets.GKE_PROJECT }}
# Build the Docker image
- name: Build
run: |-
docker build \
--tag "$GKE_ZONE-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:$GITHUB_SHA" \
--tag "$GKE_ZONE-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
./server/collaboration-service
# Push the Docker image to Google Artifact Registry
- name: Publish
run: |-
docker push "$GKE_ZONE-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:$GITHUB_SHA"
docker push "$GKE_ZONE-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest"
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |-
kubectl apply -f kubernetes/collab-service
kubectl rollout status deployment/$DEPLOYMENT_NAME
kubectl get services -o wide