Skip to content

Commit 541c3c3

Browse files
committed
deploy: use gcloud to manage triggers, trigger from GCR
The GCP UI is nicer for editing triggers, and the gcloud command now has beta support for import/export. It wants YAML format, though. Delete the json versions and replace them with freshly pulled versions, including the change to trigger from GCR. Change-Id: I3a20951d94b9a9522f28b07cc772d097679fb5a2 Reviewed-on: https://go-review.googlesource.com/c/playground/+/327349 Trust: Heschi Kreinick <heschi@google.com> Trust: Alexander Rakoczy <alex@golang.org> Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
1 parent 9814fb9 commit 541c3c3

File tree

6 files changed

+45
-68
lines changed

6 files changed

+45
-68
lines changed

Makefile

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
CLOUDBUILD_PLAYGROUND_TRIGGER_JSON := deploy/playground_trigger.json
2-
CLOUDBUILD_PLAYGROUND_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_PLAYGROUND_TRIGGER_JSON})
3-
CLOUDBUILD_GO_TRIGGER_JSON := deploy/go_trigger.json
4-
CLOUDBUILD_GO_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_GO_TRIGGER_JSON})
5-
GCLOUD_ACCESS_TOKEN := $(shell gcloud auth print-access-token)
61
LATEST_GO := $(shell go run ./cmd/latestgo)
72

83
.PHONY: docker test update-cloudbuild-trigger
@@ -28,11 +23,10 @@ test_gvisor: docker
2823
# directory)
2924
test: test_go
3025

31-
update-cloudbuild-trigger:
32-
# The gcloud CLI doesn't yet support updating a trigger.
33-
curl -H "Authorization: Bearer $(GCLOUD_ACCESS_TOKEN)" -H "Content-Type: application/json" \
34-
-d @$(CLOUDBUILD_GO_TRIGGER_JSON) \
35-
-X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_GO_TRIGGER_ID)
36-
curl -H "Authorization: Bearer $(GCLOUD_ACCESS_TOKEN)" -H "Content-Type: application/json" \
37-
-d @$(CLOUDBUILD_PLAYGROUND_TRIGGER_JSON) \
38-
-X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_PLAYGROUND_TRIGGER_ID)
26+
push-cloudbuild-triggers:
27+
gcloud beta builds triggers import --project golang-org --source deploy/go_trigger.yaml
28+
gcloud beta builds triggers import --project golang-org --source deploy/playground_trigger.yaml
29+
30+
pull-cloudbuild-triggers:
31+
gcloud beta builds triggers export --project golang-org playground-redeploy-go-release --destination deploy/go_trigger.yaml
32+
gcloud beta builds triggers export --project golang-org playground-redeploy-playground --destination deploy/playground_trigger.yaml

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,12 @@ cat /path/to/code.go | go run client.go | curl -s --upload-file - localhost:8080
2727
Playground releases automatically triggered when new Go repository tags are pushed to GitHub, or when master is pushed
2828
on the playground repository.
2929

30-
For details, see [deploy/go_trigger.json](deploy/go_trigger.json),
31-
[deploy/playground_trigger.json](deploy/playground_trigger.json),
30+
For details, see [deploy/go_trigger.yaml](deploy/go_trigger.yaml),
31+
[deploy/playground_trigger.yaml](deploy/playground_trigger.yaml),
3232
and [deploy/deploy.json](deploy/deploy.json).
3333

34-
After making changes to trigger configuration, update configuration by running the following Make target:
35-
36-
```bash
37-
make update-cloudbuild-trigger
38-
```
34+
Changes to the trigger configuration can be made to the YAML files, or in the GCP UI, which should be kept in sync
35+
using the `push-cloudbuild-trigger` and `pull-cloudbuild-trigger` make targets.
3936

4037
### Deploy via Cloud Build
4138

deploy/go_trigger.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

deploy/go_trigger.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
build:
2+
steps:
3+
- args:
4+
- clone
5+
- --depth
6+
- '1'
7+
- https://go.googlesource.com/playground
8+
name: gcr.io/cloud-builders/git
9+
- args:
10+
- builds
11+
- submit
12+
- --async
13+
- --config
14+
- deploy/deploy.json
15+
- .
16+
dir: playground
17+
name: gcr.io/cloud-builders/gcloud
18+
createTime: '2019-06-18T17:59:14.019265678Z'
19+
description: Redeploy playground on new tagged Go release
20+
id: 5a2c9e25-a71a-4adf-a785-76c3eca2ac8a
21+
name: playground-redeploy-go-release
22+
triggerTemplate:
23+
projectId: golang-org
24+
repoName: go
25+
tagName: ^go[0-9](\.[0-9]+)+$

deploy/playground_trigger.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

deploy/playground_trigger.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
createTime: '2019-07-09T19:50:40.493493139Z'
2+
description: Redeploy playground on x/playground commit
3+
filename: deploy/deploy.json
4+
id: cb46eb75-8665-4365-8e93-b8f7bfbd4807
5+
name: playground-redeploy-playground
6+
triggerTemplate:
7+
branchName: ^master$
8+
projectId: golang-org
9+
repoName: playground

0 commit comments

Comments
 (0)