-
Notifications
You must be signed in to change notification settings - Fork 102
/
constants.go
46 lines (40 loc) · 1.71 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"os"
"strings"
"time"
)
const (
pollingInterval time.Duration = 10 * time.Second
envVarRepoFullName string = "GITHUB_REPOSITORY"
envVarRunID string = "GITHUB_RUN_ID"
envVarRepoOwner string = "GITHUB_REPOSITORY_OWNER"
envVarWorkflowInitiator string = "GITHUB_ACTOR"
envVarToken string = "INPUT_SECRET"
envVarApprovers string = "INPUT_APPROVERS"
envVarMinimumApprovals string = "INPUT_MINIMUM-APPROVALS"
envVarIssueTitle string = "INPUT_ISSUE-TITLE"
envVarIssueBody string = "INPUT_ISSUE-BODY"
envVarExcludeWorkflowInitiatorAsApprover string = "INPUT_EXCLUDE-WORKFLOW-INITIATOR-AS-APPROVER"
envVarAdditionalApprovedWords string = "INPUT_ADDITIONAL-APPROVED-WORDS"
envVarAdditionalDeniedWords string = "INPUT_ADDITIONAL-DENIED-WORDS"
)
var (
additionalApprovedWords = readAdditionalWords(envVarAdditionalApprovedWords)
additionalDeniedWords = readAdditionalWords(envVarAdditionalDeniedWords)
approvedWords = append([]string{"approved", "approve", "lgtm", "yes"}, additionalApprovedWords...)
deniedWords = append([]string{"denied", "deny", "no"}, additionalDeniedWords...)
)
func readAdditionalWords(envVar string) []string {
rawValue := strings.TrimSpace(os.Getenv(envVar))
if len(rawValue) == 0 {
// Nothing else to do here.
return []string{}
}
slicedWords := strings.Split(rawValue, ",")
for i := range slicedWords {
// no leading or trailing spaces in user provided words.
slicedWords[i] = strings.TrimSpace(slicedWords[i])
}
return slicedWords
}