-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (35 loc) · 1.51 KB
/
deploy-kubernetes-engine.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
name: Deploy to Kubernetes
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Google Cloud SDK
run: |
curl -o google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-372.0.0-linux-x86_64.tar.gz
tar -xf google-cloud-sdk.tar.gz
./google-cloud-sdk/install.sh --quiet
echo "${{ secrets.GCLOUD_AUTH }}" > /tmp/gcloud.json
./google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=/tmp/gcloud.json
./google-cloud-sdk/bin/gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
- name: Configure Docker CLI
run: |
./google-cloud-sdk/bin/gcloud auth configure-docker
- name: Build and push Docker image
run: |
docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/cloud-run-ci-cd-template .
docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/cloud-run-ci-cd-template
- name: Install kubectl plugin
run: |
./google-cloud-sdk/bin/gcloud components install kubectl
- name: Set kubectl context
run: |
./google-cloud-sdk/bin/gke-gcloud container clusters get-credentials ${{ secrets.GCP_CLUSTER_NAME }} --zone ${{ secrets.GCP_CLUSTER_ZONE }} --project ${{ secrets.GCP_PROJECT_ID }}
- name: Deploy to Kubernetes
run: |
kubectl apply -f path/to/your/kubernetes/config.yaml