-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (72 loc) · 2.89 KB
/
gke-workflow.yml
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: Build and Deploy to GKE
on:
push:
branches:
- master
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
REDIS_ADDRESS: ${{ secrets.REDIS_ADDRESS }}
DB_USERNAME: ${{ secrets.TEAM_NAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: 3306
DB_NAME: ${{ secrets.TEAM_NAME }}
GKE_CLUSTER: backend-gke-cluster
GKE_REGION: asia-east1
TEAM_NAME: ${{ secrets.TEAM_NAME }}
MINIO_ENDPOINT: storage.googleapis.com
MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }}
MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }}
MINIO_REGION: US-EAST1
MINIO_BUCKET: ${{ secrets.TEAM_NAME }}-rakamin
DB_MAX_CONNECTIONS: 100
DB_MAX_IDLE_CONNECTIONS: 10
DB_MAX_LIFETIME_CONNECTIONS: 2
SERVER_READ_TIMEOUT: 60
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@master
with:
version: '290.0.1'
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
# Get the GKE credentials so we can deploy to the cluster
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --region "$GKE_REGION"
# Build the Docker image
- name: Build
run: |-
docker build \
--tag "gcr.io/$PROJECT_ID/$TEAM_NAME:$GITHUB_SHA" \
.
# Push the Docker image to Google Container Registry
- name: Publish
run: |-
docker push "gcr.io/$PROJECT_ID/$TEAM_NAME:$GITHUB_SHA"
# Set up kustomize
- name: Set up Kustomize
run: |-
curl -sfLo ./manifests/kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./manifests/kustomize
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |-
cd ./manifests
envsubst < deployment.yml.sh > deployment.yml
envsubst < service.yml.sh > service.yml
envsubst < .env.sh > .env
envsubst < kustomization.yml.sh > kustomization.yml
./kustomize build . | kubectl apply -f -
kubectl rollout status deployment/$TEAM_NAME
kubectl get services $TEAM_NAME-service -o wide