Commit 2cfaa0db authored by zauberstuhl's avatar zauberstuhl

Add custom build triggers to repositories

parent 936695e6
......@@ -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"
......
......@@ -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
......@@ -19,11 +19,24 @@
<input type="checkbox" class="form-check-input" id="optinInput" name="optin" describedby="optinHelp">
<label class="form-check-label" for="optinInput">Check if you want to opt-in on a new test</label>
<small id="optinHelp" class="form-text text-muted">
That would mean that tests are triggered if you specify <code>[ci]</code> in the PR title, message
That would mean that tests are triggered if you specify <code>[ci]</code> in the PR title, body, commit-message
or if the PR was tagged with <span class="badge badge-primary">ci</span>. If you leave the box unchecked
tests will be triggered on every pull-request. However you can skip them by writing <code>[ci skip]</code> in the PR title,
message or if the PR was tagged with <span class="badge badge-primary">ci skip</span>.
tests will be triggered on every pull-request. However you can skip them by using <code>[ci skip]</code>
in the mentioned fields or tag it with <span class="badge badge-primary">ci skip</span>.
</small>
<div class="form-group">
<label for="optinFlagInput">(optional) Custom Flags</label>
<input type="text" class="form-control" id="optinFlagInput" name="optinFlag" aria-describedby="optinFlagHelp" placeholder="default is 'ci'">
<small id="optinFlagHelp" class="form-text text-muted">
If you want to use custom build triggers for opt-in you can specify it here.
</small>
</div>
<div class="form-group">
<input type="text" class="form-control" name="optoutFlag" aria-describedby="optoutFlagHelp" placeholder="default is 'ci skip'">
<small id="optoutFlagHelp" class="form-text text-muted">
If you want to use custom build triggers for opt-out you can specify it here.
</small>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment