-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflow.go
43 lines (37 loc) · 959 Bytes
/
workflow.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
package main
import (
"fmt"
"os"
"strconv"
"strings"
"time"
)
type workflowEnvironment struct {
repo string
repoOwner string
headSha string
baseBranch string
pollingInterval time.Duration
}
func newWorkflowEnvironment(repo string, repoOwner string, headSha string, baseBranch string, pollingIntervalInput string) (*workflowEnvironment, error) {
pollingInterval, err := strconv.Atoi(pollingIntervalInput)
if err != nil {
fmt.Printf("error converting to int: %v\n", err)
os.Exit(1)
}
duration := time.Duration(pollingInterval) * time.Second
repoOwnerAndName := strings.Split(repo, "/")
var repoName string
if len(repoOwnerAndName) == 2 {
repoName = repoOwnerAndName[1]
} else {
repoName = repoOwnerAndName[0]
}
return &workflowEnvironment{
repo: repoName,
repoOwner: repoOwner,
headSha: headSha,
baseBranch: baseBranch,
pollingInterval: duration,
}, nil
}