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>
This commit is contained in:
Heschi Kreinick 2021-06-11 16:28:15 -04:00
Родитель 9814fb9de2
Коммит 541c3c365c
6 изменённых файлов: 45 добавлений и 68 удалений

Просмотреть файл

@ -1,8 +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_GO_TRIGGER_ID := $(shell jq -r .id ${CLOUDBUILD_GO_TRIGGER_JSON})
GCLOUD_ACCESS_TOKEN := $(shell gcloud auth print-access-token)
LATEST_GO := $(shell go run ./cmd/latestgo)
.PHONY: docker test update-cloudbuild-trigger
@ -28,11 +23,10 @@ test_gvisor: docker
# 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_GO_TRIGGER_JSON) \
-X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_GO_TRIGGER_ID)
curl -H "Authorization: Bearer $(GCLOUD_ACCESS_TOKEN)" -H "Content-Type: application/json" \
-d @$(CLOUDBUILD_PLAYGROUND_TRIGGER_JSON) \
-X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_PLAYGROUND_TRIGGER_ID)
push-cloudbuild-triggers:
gcloud beta builds triggers import --project golang-org --source deploy/go_trigger.yaml
gcloud beta builds triggers import --project golang-org --source deploy/playground_trigger.yaml
pull-cloudbuild-triggers:
gcloud beta builds triggers export --project golang-org playground-redeploy-go-release --destination deploy/go_trigger.yaml
gcloud beta builds triggers export --project golang-org playground-redeploy-playground --destination deploy/playground_trigger.yaml

Просмотреть файл

@ -27,15 +27,12 @@ cat /path/to/code.go | go run client.go | curl -s --upload-file - localhost:8080
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

Просмотреть файл

@ -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",
"."
]
}
]
}
}

25
deploy/go_trigger.yaml Normal file
Просмотреть файл

@ -0,0 +1,25 @@
build:
steps:
- args:
- clone
- --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: '2019-06-18T17:59:14.019265678Z'
description: Redeploy playground on new tagged Go release
id: 5a2c9e25-a71a-4adf-a785-76c3eca2ac8a
name: playground-redeploy-go-release
triggerTemplate:
projectId: golang-org
repoName: go
tagName: ^go[0-9](\.[0-9]+)+$

Просмотреть файл

@ -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"
}

Просмотреть файл

@ -0,0 +1,9 @@
createTime: '2019-07-09T19:50:40.493493139Z'
description: Redeploy playground on x/playground commit
filename: deploy/deploy.json
id: cb46eb75-8665-4365-8e93-b8f7bfbd4807
name: playground-redeploy-playground
triggerTemplate:
branchName: ^master$
projectId: golang-org
repoName: playground