Skip to content

Commit

Permalink
add merge PR support to Github
Browse files Browse the repository at this point in the history
  • Loading branch information
davidwin93 committed Oct 13, 2023
1 parent 6a37232 commit afc35b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/vcs/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ func (c *Client) GetMergeRequestApprovals(ctx context.Context, id int, project s
}
return pr, nil
}
func (c *Client) MergeMR(ctx context.Context, mrIID int, project string) error {
projectParts, err := splitFullName(project)
if err != nil {
utils.CreatePermanentError(err)
}
_, _, err = c.client.PullRequests.Merge(c.ctx, projectParts[0], projectParts[1], mrIID, "", nil)

return err
}

// Go over all comments on a PR, trying to grab any old TFC run urls and deleting the bodies
func (c *Client) GetOldRunUrls(ctx context.Context, prID int, fullName string, rootCommentID int) (string, error) {
Expand Down
8 changes: 7 additions & 1 deletion pkg/vcs/github/run_events_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@ func (w *RunEventsWorker) postRunStatusComment(ctx context.Context, run *tfe.Run
)

}

if run.Status == tfe.RunApplied {
if len(run.TargetAddrs) > 0 {
return
}
// The applying phase of a run has completed.
w.client.MergeMR(ctx, rmd.GetMRInternalID(), rmd.GetMRProjectNameWithNamespace())
}
}

0 comments on commit afc35b6

Please sign in to comment.