-
Notifications
You must be signed in to change notification settings - Fork 25
65 lines (54 loc) · 1.8 KB
/
app6-gke.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
name: Build and Deploy app6 to GKE
on:
push:
branches:
- master
paths:
- 'app6/**'
- '.github/workflows/app6-gke.yml'
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: dwk-cluster
GKE_ZONE: europe-north1-b
IMAGE: dwk-environments
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GKE_PROJECT }}
service_account_key: ${{ secrets.GKE_SA_KEY }}
export_default_credentials: true
# 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" --zone "$GKE_ZONE"
# Build the Docker image
- name: Build
run: |-
cd ./app6/ && docker build \
--tag "gcr.io/$PROJECT_ID/$IMAGE:${GITHUB_REF#refs/heads/}-$GITHUB_SHA" \
.
# Push the Docker image to Google Container Registry
- name: Publish
run: |-
docker push "gcr.io/$PROJECT_ID/$IMAGE:${GITHUB_REF#refs/heads/}-$GITHUB_SHA"
# Set up kustomize
- name: Set up Kustomize
uses: imranismail/setup-kustomize@v1
# Deploy the Docker image to the GKE cluster
- name: Deploy
run: |-
cd ./app6/
kustomize edit set image gcr.io/PROJECT_ID/IMAGE:TAG=gcr.io/$PROJECT_ID/$IMAGE:${GITHUB_REF#refs/heads/}-$GITHUB_SHA
kustomize build . | kubectl apply -f -
kubectl rollout status deployment/$IMAGE
kubectl get services -o wide