[dev.go2go] 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: If05944fdd6cca6d7f72b56ade191a3b00c333b9e
Reviewed-on: https://go-review.googlesource.com/c/playground/+/327389
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
diff --git a/Makefile b/Makefile
index fd80962..b0298f9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,3 @@
-CLOUDBUILD_PLAYGROUND_TRIGGER_JSON := deploy/playground_trigger.json
-CLOUDBUILD_PLAYGROUND_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_PLAYGROUND_TRIGGER_JSON})
-CLOUDBUILD_GO_TRIGGER_JSON := deploy/go_trigger.json
-CLOUDBUILD_GO2GOPLAY_TRIGGER_JSON := deploy/go2goplay_trigger.json
-CLOUDBUILD_GO2GOPLAY_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_GO2GOPLAY_TRIGGER_JSON})
-CLOUDBUILD_GO_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_GO_TRIGGER_JSON})
-GCLOUD_ACCESS_TOKEN := $(shell gcloud auth print-access-token)
-
.PHONY: docker test update-cloudbuild-trigger
docker:
@@ -29,9 +21,8 @@
# directory)
test: test_go
-update-cloudbuild-trigger:
- # The gcloud CLI doesn't yet support updating a trigger.
- curl -H "Authorization: Bearer $(GCLOUD_ACCESS_TOKEN)" -H "Content-Type: application/json" \
- -d @$(CLOUDBUILD_GO2GOPLAY_TRIGGER_JSON) \
- -X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_GO2GOPLAY_TRIGGER_ID)
+push-cloudbuild-triggers:
+ gcloud beta builds triggers import --project golang-org --source deploy/go2goplay_trigger.yaml
+pull-cloudbuild-triggers:
+ gcloud beta builds triggers export --project golang-org go2go-redeploy-playground --destination deploy/go2goplay_trigger.yaml
diff --git a/README.md b/README.md
index cf8d4c7..69d60ce 100644
--- a/README.md
+++ b/README.md
@@ -25,15 +25,12 @@
Playground releases automatically triggered when new Go repository tags are pushed to GitHub, or when master is pushed
on the playground repository.
-For details, see [deploy/go_trigger.json](deploy/go_trigger.json),
-[deploy/playground_trigger.json](deploy/playground_trigger.json),
+For details, see [deploy/go_trigger.yaml](deploy/go_trigger.yaml),
+[deploy/playground_trigger.yaml](deploy/playground_trigger.yaml),
and [deploy/deploy.json](deploy/deploy.json).
-After making changes to trigger configuration, update configuration by running the following Make target:
-
-```bash
-make update-cloudbuild-trigger
-```
+Changes to the trigger configuration can be made to the YAML files, or in the GCP UI, which should be kept in sync
+using the `push-cloudbuild-trigger` and `pull-cloudbuild-trigger` make targets.
### Deploy via Cloud Build
diff --git a/deploy/go2goplay_trigger.json b/deploy/go2goplay_trigger.json
deleted file mode 100644
index b6021d4..0000000
--- a/deploy/go2goplay_trigger.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "id": "0d417735-105e-4887-a8f5-9d37aedbecb9",
- "description": "Go repository dev.go2go branch trigger for x/playground",
- "github": {
- "name": "go",
- "owner": "golang",
- "push": {
- "branch": "^dev\\.go2go$"
- }
- },
- "build": {
- "steps": [
- {
- "name": "gcr.io/cloud-builders/git",
- "args": [
- "clone",
- "-b",
- "dev.go2go",
- "--depth",
- "1",
- "https://go.googlesource.com/playground"
- ]
- },
- {
- "dir": "playground",
- "name": "gcr.io/cloud-builders/gcloud",
- "args": [
- "builds",
- "submit",
- "--async",
- "--config",
- "deploy/deploy.json",
- "."
- ]
- }
- ]
- }
-}
diff --git a/deploy/go2goplay_trigger.yaml b/deploy/go2goplay_trigger.yaml
new file mode 100644
index 0000000..00499a4
--- /dev/null
+++ b/deploy/go2goplay_trigger.yaml
@@ -0,0 +1,27 @@
+build:
+ steps:
+ - args:
+ - clone
+ - -b
+ - dev.go2go
+ - --depth
+ - '1'
+ - https://go.googlesource.com/playground
+ name: gcr.io/cloud-builders/git
+ - args:
+ - builds
+ - submit
+ - --async
+ - --config
+ - deploy/deploy.json
+ - .
+ dir: playground
+ name: gcr.io/cloud-builders/gcloud
+createTime: '2020-09-24T18:59:38.698943467Z'
+description: Redeploy playground on dev.go2go commit
+id: 0d417735-105e-4887-a8f5-9d37aedbecb9
+name: go2go-redeploy-playground
+triggerTemplate:
+ branchName: ^dev\.go2go$
+ projectId: golang-org
+ repoName: go
diff --git a/deploy/go_trigger.json b/deploy/go_trigger.json
deleted file mode 100644
index b7e7ff5..0000000
--- a/deploy/go_trigger.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "id": "5a2c9e25-a71a-4adf-a785-76c3eca2ac8a",
- "description": "Go repository release trigger for x/playground",
- "github": {
- "name": "go",
- "owner": "golang",
- "push": {
- "tag": "^go[0-9](\\.[0-9]+)+$"
- }
- },
- "build": {
- "steps": [
- {
- "name": "gcr.io/cloud-builders/git",
- "args": [
- "clone",
- "--depth",
- "1",
- "https://go.googlesource.com/playground"
- ]
- },
- {
- "dir": "playground",
- "name": "gcr.io/cloud-builders/gcloud",
- "args": [
- "builds",
- "submit",
- "--async",
- "--config",
- "deploy/deploy.json",
- "."
- ]
- }
- ]
- }
-}
diff --git a/deploy/playground_trigger.json b/deploy/playground_trigger.json
deleted file mode 100644
index 3685fe5..0000000
--- a/deploy/playground_trigger.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "id": "cb46eb75-8665-4365-8e93-b8f7bfbd4807",
- "description": "Playground repository release trigger for x/playground",
- "github": {
- "name": "playground",
- "owner": "golang",
- "push": {
- "branch": "^master$"
- }
- },
- "filename": "deploy/deploy.json"
-}