-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (58 loc) · 1.92 KB
/
gke.yml
File metadata and controls
74 lines (58 loc) · 1.92 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
71
72
73
74
name: Deploy to GKE
on:
push:
branches:
- master
env:
PROJECT_ID: winter-framework
IMAGE_NAME: winter-getting-started
CLUSTER_NAME: autopilot-cluster-1
CLUSTER_ZONE: europe-central2
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and tag Docker image
run: |
docker build -t $IMAGE_NAME .
docker tag $IMAGE_NAME gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
- id: 'auth'
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Configure Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: '${{ env.PROJECT_ID }}'
- name: Authenticate Docker with Google Artifact Registry
run: gcloud auth configure-docker
- name: Push Docker image to Google Artifact Registry
run: docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
deploy:
runs-on: ubuntu-latest
needs: [build]
environment:
name: GKE
url: ${{ steps.deploy.outputs.service_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: 'auth'
uses: google-github-actions/auth@v1
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Configure Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: '${{ env.PROJECT_ID }}'
- name: Authenticate Docker with Google Artifact Registry
run: gcloud auth configure-docker
- uses: simenandre/setup-gke-gcloud-auth-plugin@v1
- name: Deploy to GKE
id: deploy
run: |
gcloud container clusters get-credentials $CLUSTER_NAME --zone $CLUSTER_ZONE
kubectl apply -f deployment.yaml
echo "service_url=http://$(kubectl get service winter-getting-started-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')" >> $GITHUB_OUTPUT