-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
44 lines (35 loc) · 941 Bytes
/
helpers.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
package main
import (
"context"
"fmt"
"os"
)
func handleInterrupt(ctx context.Context) {
closeComment := "Workflow cancelled."
fmt.Println(closeComment)
}
func validateInput() error {
missingEnvVars := []string{}
if os.Getenv(envVarRepoName) == "" {
missingEnvVars = append(missingEnvVars, envVarRepoName)
}
if os.Getenv(envVarHeadSha) == "" {
missingEnvVars = append(missingEnvVars, envVarHeadSha)
}
if os.Getenv(envVarBaseBranch) == "" {
missingEnvVars = append(missingEnvVars, envVarBaseBranch)
}
if os.Getenv(envVarRepoOwner) == "" {
missingEnvVars = append(missingEnvVars, envVarRepoOwner)
}
if os.Getenv(envVarPollingInterval) == "" {
missingEnvVars = append(missingEnvVars, envVarPollingInterval)
}
if os.Getenv(envVarToken) == "" {
missingEnvVars = append(missingEnvVars, envVarToken)
}
if len(missingEnvVars) > 0 {
return fmt.Errorf("missing env vars: %v", missingEnvVars)
}
return nil
}