-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
86 lines (84 loc) · 3.35 KB
/
cloudbuild.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
steps:
- name: "curlimages/curl:latest"
id: Notify Start
allowFailure: true
entrypoint: sh
secretEnv:
- _WEBHOOK_URL
args:
- -c
- |
curl -X POST "$$_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "Google Cloud Build",
"content": "Cloud Run service $_SERVICE_NAME starting deploy:\n- Commit: `'"$COMMIT_SHA"'`\n- Build ID: `'"$BUILD_ID"'`\n- Trigger ID: `'"$_TRIGGER_ID"'`\n\n[View commit on GitHub](https://github.com/gyrinx-app/gyrinx/commit/$COMMIT_SHA)\n[View logs on Google Cloud](https://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=$PROJECT_ID) — you must have an account with access to the project"
}'
- name: gcr.io/cloud-builders/docker
args:
- build
- "--no-cache"
- "-t"
- >-
$_AR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
- .
- "-f"
- Dockerfile
id: Build
- name: gcr.io/cloud-builders/docker
args:
- push
- >-
$_AR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
id: Push
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk:slim"
args:
- run
- services
- update
- $_SERVICE_NAME
- "--platform=managed"
- >-
--image=$_AR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
- >-
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID
- "--region=$_DEPLOY_REGION"
- "--quiet"
id: Deploy
entrypoint: gcloud
- name: "curlimages/curl:latest"
id: Notify Deploy
waitFor: ["Deploy"]
allowFailure: true
entrypoint: sh
secretEnv:
- _WEBHOOK_URL
args:
- -c
- |
curl -X POST "$$_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"username": "Google Cloud Build",
"content": "Cloud Run service $_SERVICE_NAME has been deployed:\n- Commit: `'"$COMMIT_SHA"'`\n- Build ID: `'"$BUILD_ID"'`\n- Trigger ID: `'"$_TRIGGER_ID"'`\n\n[View commit on GitHub](https://github.com/gyrinx-app/gyrinx/commit/$COMMIT_SHA)\n[View logs on Google Cloud](https://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=$PROJECT_ID) — you must have an account with access to the project"
}'
images:
- >-
$_AR_HOSTNAME/$PROJECT_ID/cloud-run-source-deploy/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
options:
substitutionOption: ALLOW_LOOSE
logging: CLOUD_LOGGING_ONLY
substitutions:
_TRIGGER_ID: bd49e415-bc5c-411a-a19d-ec77599c3ddf
_AR_HOSTNAME: europe-west2-docker.pkg.dev
_PLATFORM: managed
_SERVICE_NAME: gyrinx
_DEPLOY_REGION: europe-west2
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/gyrinx-app-boostrap-discord-webhook-url/versions/latest
env: "_WEBHOOK_URL"
tags:
- gcp-cloud-build-deploy-cloud-run
- gcp-cloud-build-deploy-cloud-run-managed
- gyrinx