From d40a45be6498b62860848ab27a8bbc3dd549946c Mon Sep 17 00:00:00 2001 From: cpanato Date: Tue, 23 Jan 2024 13:16:13 +0100 Subject: [PATCH] add retry for create pull request Signed-off-by: cpanato --- github/github.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/github/github.go b/github/github.go index 765b427d..a8a311ca 100644 --- a/github/github.go +++ b/github/github.go @@ -393,13 +393,12 @@ func (g *githubClient) CreatePullRequest( MaintainerCanModify: github.Bool(true), } - pr, _, err := g.PullRequests.Create(ctx, owner, repo, newPullRequest) - if err != nil { - return pr, fmt.Errorf("creating pull request: %w", err) + for shouldRetry := internal.DefaultGithubErrChecker(); ; { + pr, _, err := g.PullRequests.Create(ctx, owner, repo, newPullRequest) + if !shouldRetry(err) { + return pr, err + } } - - logrus.Infof("Successfully created PR #%d", pr.GetNumber()) - return pr, nil } func (g *githubClient) RequestPullRequestReview( @@ -875,6 +874,7 @@ func (g *GitHub) CreatePullRequest( return pr, err } + logrus.Infof("Successfully created PR #%d", pr.GetNumber()) return pr, nil }