forked from wulfland/AccelerateDevOps
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (59 loc) · 2.06 KB
/
Copy pathDeploy-GKE.yml
File metadata and controls
70 lines (59 loc) · 2.06 KB
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
name: Deploy-GKE
on: [workflow_dispatch]
env:
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: xyz-demo-cluster
GKE_APP_NAME: xyz-demo-shop
GKE_SERVICE: xyz-service
GKE_SERVICE_ACCOUNT: xyz-serviceaccount
GKE_DEPLOYMENT_NAME: xyz-demo-shop-deployment
GKE_REGION: europe-west3
GKE_ZONE: europe-west3-a
jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.6.0
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
export_default_credentials: true
# Build the Docker image
- name: Build and Push
working-directory: ch9_release/src/Tailwind.Traders.Web
run: |-
docker build \
--tag "$GKE_REGION-docker.pkg.dev/$GKE_PROJECT/$GKE_PROJECT/$GKE_APP_NAME:$GITHUB_SHA" \
--build-arg GITHUB_SHA="$GITHUB_SHA" \
--build-arg GITHUB_REF="$GITHUB_REF" \
.
gcloud auth configure-docker $GKE_REGION-docker.pkg.dev --quiet
docker push "$GKE_REGION-docker.pkg.dev/$GKE_PROJECT/$GKE_PROJECT/$GKE_APP_NAME:$GITHUB_SHA"
Deploy:
runs-on: ubuntu-latest
environment: prod
needs: Build
steps:
- name: Checkout
uses: actions/checkout@v3
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@v0.6.0
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
export_default_credentials: true
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@v3.0.0
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
# Deploy the new Docker image to the GKE cluster
- name: Deploy
working-directory: ch9_release/src/Tailwind.Traders.Web
run: |-
envsubst < Service.yml | kubectl apply -f -
envsubst < Deployment.yml | kubectl apply -f -