Skip to content

Commit 9abf781

Browse files
committed
Update deploy-staging workflow to push to staging cluster
1 parent 21a0f8a commit 9abf781

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

.github/workflows/deploy-staging.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
push:
44
branches:
55
- chore/github-actions
6+
env:
7+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
8+
GKE_CLUSTER: p5js-web-editor-cluster
9+
GKE_ZONE: us-east1-c
10+
DEPLOYMENT_NAME: web-editor-node
11+
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor-staging
612
jobs:
713
push_to_registry:
814
environment: staging
@@ -25,6 +31,38 @@ jobs:
2531
file: ./Dockerfile
2632
pull: true
2733
push: true
28-
tags: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor-staging:${{ github.sha }}
34+
tags: |
35+
$IMAGE:${{ github.sha }}
36+
$IMAGE:latest
2937
target: production
38+
# Setup gcloud CLI
39+
- uses: google-github-actions/[email protected]
40+
with:
41+
service_account_key: ${{ secrets.GKE_SA_KEY }}
42+
project_id: ${{ secrets.GKE_PROJECT }}
43+
44+
# Configure docker to use the gcloud command-line tool as a credential helper
45+
- run: |-
46+
gcloud --quiet auth configure-docker
47+
48+
# Get the GKE credentials so we can deploy to the cluster
49+
- uses: google-github-actions/[email protected]
50+
with:
51+
cluster_name: ${{ env.GKE_CLUSTER }}
52+
location: ${{ env.GKE_ZONE }}
53+
credentials: ${{ secrets.GKE_SA_KEY }}
54+
55+
# Set up kustomize
56+
- name: Set up Kustomize
57+
run: |-
58+
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
59+
chmod u+x ./kustomize
60+
61+
# Deploy the Docker image to the GKE cluster
62+
- name: Deploy
63+
run: |-
64+
./kustomize edit set image web-editor-app=index.docker.io/$IMAGE:$GITHUB_SHA --namespace=staging
65+
./kustomize build . | kubectl apply -f -
66+
kubectl rollout status deployment/$DEPLOYMENT_NAME --namespace=staging
67+
kubectl get services -o wide --namespace=staging
3068

0 commit comments

Comments
 (0)