Compare commits
2 Commits
10b487d09d
...
214e8c60ef
Author | SHA1 | Date |
---|---|---|
Julien Fastré | 214e8c60ef | |
Julien Fastré | 45a64e18f4 |
11
main.go
11
main.go
|
@ -67,6 +67,7 @@ func main() {
|
||||||
ctx, err := githubactions.Context()
|
ctx, err := githubactions.Context()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
githubactions.Fatalf("could not get context: %v", err.Error())
|
githubactions.Fatalf("could not get context: %v", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
token := os.Getenv("GITHUB_TOKEN")
|
token := os.Getenv("GITHUB_TOKEN")
|
||||||
|
@ -75,18 +76,16 @@ func main() {
|
||||||
config, err := ParseActionConfig(*ctx)
|
config, err := ParseActionConfig(*ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
githubactions.Fatalf("%v", err.Error())
|
githubactions.Fatalf("%v", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pr, err := createPullRequest(ctx.ServerURL, token, *config)
|
pr, err := createPullRequest(ctx.ServerURL, token, *config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
githubactions.Fatalf("Error while creating pr: %v", err.Error())
|
githubactions.Fatalf("Error while creating pr: %v", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if pr != nil {
|
fmt.Printf("Created PR with id %d\n", pr.ID)
|
||||||
fmt.Printf("Created PR with id %d\n", pr.ID)
|
|
||||||
} else {
|
|
||||||
fmt.Printf("No PR created\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
githubactions.SetOutput("pull-request-number", strconv.FormatInt(pr.Index, 10))
|
githubactions.SetOutput("pull-request-number", strconv.FormatInt(pr.Index, 10))
|
||||||
githubactions.SetOutput("pull-request-url", pr.URL)
|
githubactions.SetOutput("pull-request-url", pr.URL)
|
||||||
|
@ -234,7 +233,7 @@ func createPullRequest(apiUrl string, token string, config CreatePrConfig) (*git
|
||||||
}
|
}
|
||||||
|
|
||||||
if has {
|
if has {
|
||||||
return nil, nil
|
return nil, errors.New("PR already exists for this head branch")
|
||||||
}
|
}
|
||||||
|
|
||||||
pr, err := agent.createPullRequestGitea(config)
|
pr, err := agent.createPullRequestGitea(config)
|
||||||
|
|
Loading…
Reference in New Issue