playground: trigger playground deploys from master
This change adds configuration to trigger a playground deploy when
master is updated. Configuration for deploying a build with the latest
release of go is shared in deploy/deploy.json. Cloud Build
configurations have been moved to the deploy directory.
In order to help share configurations, the build triggers will create a
separate deployment build asynchronously.
The README is updated to help describe common deployment scenarios.
Tested deploy steps with README instructions.
Updates golang/go#32606
Change-Id: I6eced05d3aa2904135e95e8b40e5a30a5b0b0488
Reviewed-on: https://go-review.googlesource.com/c/playground/+/185341
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/Makefile b/Makefile
index b0c8651..2cf568d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
-CLOUDBUILD_TRIGGER_ID := $(shell jq -r .id cloudbuild_trigger.json)
-CLOUDBUILD_TRIGGER_JSON := cloudbuild_trigger.json
+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)
.PHONY: docker test update-cloudbuild-trigger
@@ -17,5 +19,8 @@
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_TRIGGER_JSON) \
- -X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_TRIGGER_ID)
+ -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)
diff --git a/README.md b/README.md
index fffee73..6b8d71c 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,31 @@
## Deployment
+### Deployment Triggers
+
+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),
+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
+```
+
+### Deploy via Cloud Build
+
+The Cloud Build configuration will always build and deploy with the latest supported release of Go.
+
+```bash
+gcloud builds submit --config deploy/deploy.json .
+```
+
+### Deploy via gcloud app deploy
+
Building the playground Docker container takes more than the default 10 minute time limit of cloud build, so increase
its timeout first (note, `app/cloud_build_timeout` is a global configuration value):
@@ -42,17 +67,6 @@
gcloud --project=golang-org --account=you@google.com app deploy app.yaml
```
-### Deployment Triggers
-
-Playground releases are also triggered when new tags are pushed to Github. The Cloud Build trigger configuration is
-defined in [cloudbuild_trigger.json](cloudbuild_trigger.json).
-
-Triggers can be updated by running the following Make target:
-
-```bash
-make update-cloudbuild-trigger
-```
-
## Contributing
To submit changes to this repository, see
diff --git a/cloudbuild_trigger.json b/cloudbuild_trigger.json
deleted file mode 100644
index 620d320..0000000
--- a/cloudbuild_trigger.json
+++ /dev/null
@@ -1,68 +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"
- ]
- },
- {
- "name": "golang",
- "entrypoint": "bash",
- "args": [
- "-c",
- "go get golang.org/x/build/maintner/maintq && cp /go/bin/maintq /workspace/maintq"
- ]
- },
- {
- "name": "debian:stretch",
- "entrypoint": "bash",
- "args": [
- "-c",
- "apt-get update && apt-get install -y ca-certificates && ./maintq list-releases | head -n 1 | sed -re 's/^.*tag_name:\"(go[0-9](\\.[0-9]+)+)\".*$/\\1/g' > /workspace/latestgo"
- ]
- },
- {
- "dir": "playground",
- "name": "gcr.io/cloud-builders/docker",
- "entrypoint": "bash",
- "args": [
- "-c",
- "docker build --build-arg GO_VERSION=`cat /workspace/latestgo` -t gcr.io/$PROJECT_ID/playground ."
- ]
- },
- {
- "name": "gcr.io/cloud-builders/docker",
- "args": [
- "push",
- "gcr.io/$PROJECT_ID/playground"
- ]
- },
- {
- "dir": "playground",
- "name": "gcr.io/cloud-builders/gcloud",
- "args": [
- "app",
- "deploy",
- "app.yaml",
- "--project=$PROJECT_ID",
- "--image-url=gcr.io/$PROJECT_ID/playground:latest"
- ]
- }
- ],
- "timeout": "1800s"
- }
-}
diff --git a/deploy/deploy.json b/deploy/deploy.json
new file mode 100644
index 0000000..72d9415
--- /dev/null
+++ b/deploy/deploy.json
@@ -0,0 +1,46 @@
+{
+ "steps": [
+ {
+ "name": "golang",
+ "entrypoint": "bash",
+ "args": [
+ "-c",
+ "cd go && go get golang.org/x/build/maintner/maintq && cp /go/bin/maintq /workspace/maintq"
+ ]
+ },
+ {
+ "name": "debian:stretch",
+ "entrypoint": "bash",
+ "args": [
+ "-c",
+ "apt-get update && apt-get install -y ca-certificates && ./maintq list-releases | head -n 1 | sed -re 's/^.*tag_name:\"(go[0-9](\\.[0-9]+)+)\".*$/\\1/g' > /workspace/latestgo"
+ ]
+ },
+ {
+ "name": "gcr.io/cloud-builders/docker",
+ "entrypoint": "bash",
+ "args": [
+ "-c",
+ "docker build --build-arg GO_VERSION=`cat /workspace/latestgo` -t gcr.io/$PROJECT_ID/playground ."
+ ]
+ },
+ {
+ "name": "gcr.io/cloud-builders/docker",
+ "args": [
+ "push",
+ "gcr.io/$PROJECT_ID/playground"
+ ]
+ },
+ {
+ "name": "gcr.io/cloud-builders/gcloud",
+ "args": [
+ "app",
+ "deploy",
+ "app.yaml",
+ "--project=$PROJECT_ID",
+ "--image-url=gcr.io/$PROJECT_ID/playground:latest"
+ ]
+ }
+ ],
+ "timeout": "1800s"
+}
diff --git a/deploy/go_trigger.json b/deploy/go_trigger.json
new file mode 100644
index 0000000..b7e7ff5
--- /dev/null
+++ b/deploy/go_trigger.json
@@ -0,0 +1,36 @@
+{
+ "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
new file mode 100644
index 0000000..3685fe5
--- /dev/null
+++ b/deploy/playground_trigger.json
@@ -0,0 +1,12 @@
+{
+ "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"
+}