diff --git a/frontend.go b/frontend.go index 316dcd6..2d77045 100644 --- a/frontend.go +++ b/frontend.go @@ -104,18 +104,25 @@ func resultPage(w http.ResponseWriter, r *http.Request) { return } - var optIn bool - if strings.ToUpper(r.URL.Query().Get("optin")) == "ON" { - optIn = true - } - secret := Secret(16) repo := Repo{ Project: project, Slug: repo, Token: accessToken, Secret: secret, - OptIn: optIn, + } + + // set the repo to opt-in + if strings.ToUpper(r.URL.Query().Get("optin")) == "ON" { + repo.OptIn = true + } + // define custom opt-in flag + if r.URL.Query().Get("optinFlag") != "" { + repo.OptInFlag = r.URL.Query().Get("optinFlag") + } + // define custom opt-out flag + if r.URL.Query().Get("optoutFlag") != "" { + repo.OptOutFlag = r.URL.Query().Get("optoutFlag") } name := "web" diff --git a/repo.go b/repo.go index 2e14d0a..911e73f 100644 --- a/repo.go +++ b/repo.go @@ -28,6 +28,8 @@ type Repo struct { Token string Secret string OptIn bool + OptInFlag string `gorm:"default:'ci'"` + OptOutFlag string `gorm:"default:'ci skip'"` } type Repos []Repo diff --git a/templates/auth.html b/templates/auth.html index b15865f..27daf07 100644 --- a/templates/auth.html +++ b/templates/auth.html @@ -19,11 +19,24 @@ - That would mean that tests are triggered if you specify [ci] in the PR title, message + That would mean that tests are triggered if you specify [ci] in the PR title, body, commit-message or if the PR was tagged with ci. If you leave the box unchecked - tests will be triggered on every pull-request. However you can skip them by writing [ci skip] in the PR title, - message or if the PR was tagged with ci skip. + tests will be triggered on every pull-request. However you can skip them by using [ci skip] + in the mentioned fields or tag it with ci skip. +
+ + + + If you want to use custom build triggers for opt-in you can specify it here. + +
+
+ + + If you want to use custom build triggers for opt-out you can specify it here. + +
diff --git a/webhook.go b/webhook.go index 5dc08d5..e1563d0 100644 --- a/webhook.go +++ b/webhook.go @@ -81,9 +81,9 @@ func webhook(w http.ResponseWriter, r *http.Request) { //} var flagExists = false - var buildFlag = "ci skip" + var buildFlag = repo.OptOutFlag if repo.OptIn { - buildFlag = "ci" + buildFlag = repo.OptInFlag } // check PR title and body for [ci] or [ci skip] flag