-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
29 lines (27 loc) · 895 Bytes
/
cloudbuild.yaml
File metadata and controls
29 lines (27 loc) · 895 Bytes
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
steps:
# Step 1: Generate access token and write Docker config for GCR
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
TOKEN=$(gcloud auth print-access-token)
echo "{\"auths\":{\"gcr.io\":{\"auth\":\"$(echo -n "oauth2accesstoken:$$TOKEN" | base64)\"}}}" > /docker-config/config.json
volumes:
- name: 'docker-config'
path: '/docker-config'
# Step 2: Run Gradle build with Jib using the token-based Docker config
- name: 'gradle:8-jdk21'
entrypoint: 'gradle'
args: ['clean', 'jib']
env:
- 'DOCKER_CONFIG=/docker-config'
volumes:
- name: 'docker-config'
path: '/docker-config'
# Step 3: Apply Kubernetes manifests to GKE cluster
- name: 'gcr.io/cloud-builders/kubectl'
args: ['apply', '-f', 'k8s/']
env:
- 'CLOUDSDK_COMPUTE_ZONE=us-west1-b'
- 'CLOUDSDK_CONTAINER_CLUSTER=allprojects-cluster'