diff --git a/README.md b/README.md index 0f980f15..2477e62a 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,24 @@ The main issue tracker for the tour is located at https://github.com/golang/go/issues. Prefix your issue with "tour:" in the subject line, so it is easy to find. +## Deploying + +1. To deploy tour.golang.org, run: + + ``` + GO111MODULE=on gcloud --project=golang-org app deploy --no-promote app.yaml + ``` + + This will create a new version, which can be viewed within the + [golang-org GCP project](https://console.cloud.google.com/appengine/versions?project=golang-org&serviceId=tour). + +2. Check that the deployed version looks OK (click the version link in GCP). + +3. If all is well, click "Migrate Traffic" to move 100% of the tour.golang.org + traffic to the new version. + +4. You're done. + ## License Unless otherwise noted, the go-tour source files are distributed diff --git a/app.yaml b/app.yaml index fcd8f178..5ba09d0a 100644 --- a/app.yaml +++ b/app.yaml @@ -1,8 +1,17 @@ service: tour -runtime: go111 +runtime: go112 env_variables: GOLANGORG_CHECK_COUNTRY: true + TOUR_ANALYTICS: | + + default_expiration: "7d" diff --git a/appengine.go b/appengine.go index 93981600..c6201a3e 100644 --- a/appengine.go +++ b/appengine.go @@ -7,6 +7,7 @@ package main import ( "bufio" "bytes" + "html/template" "io" "log" "net/http" @@ -18,6 +19,7 @@ import ( func gaeMain() { prepContent = gaePrepContent socketAddr = gaeSocketAddr + analyticsHTML = template.HTML(os.Getenv("TOUR_ANALYTICS")) if err := initTour(".", "HTTPTransport"); err != nil { log.Fatal(err) diff --git a/local.go b/local.go index 21421af5..7702c8fb 100644 --- a/local.go +++ b/local.go @@ -8,6 +8,7 @@ import ( "flag" "fmt" "go/build" + "html/template" "io" "log" "net" @@ -224,3 +225,6 @@ var prepContent = func(r io.Reader) io.Reader { return r } // socketAddr returns the WebSocket handler address. var socketAddr = func() string { return "ws://" + httpAddr + socketPath } + +// analyticsHTML is optional analytics HTML to insert at the beginning of . +var analyticsHTML template.HTML diff --git a/template/index.tmpl b/template/index.tmpl index 01f94b47..837dc773 100755 --- a/template/index.tmpl +++ b/template/index.tmpl @@ -2,7 +2,7 @@ - +{{.AnalyticsHTML}} A Tour of Go diff --git a/tour.go b/tour.go index 1a742856..806b54c1 100644 --- a/tour.go +++ b/tour.go @@ -57,9 +57,10 @@ func initTour(root, transport string) error { buf := new(bytes.Buffer) data := struct { - SocketAddr string - Transport template.JS - }{socketAddr(), template.JS(transport)} + AnalyticsHTML template.HTML + SocketAddr string + Transport template.JS + }{analyticsHTML, socketAddr(), template.JS(transport)} if err := ui.Execute(buf, data); err != nil { return fmt.Errorf("render UI: %v", err)