Skip to content

Commit 0e0d46e

Browse files
authored
Merge pull request #4 from etsy/tweak-pr-description
clean up PR title and description
2 parents 9fdc5dc + 48dd4ac commit 0e0d46e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

gitops/git/github_app/github_app.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func CreatePR(from, to, title, body string) error {
9797
return err
9898
}
9999

100-
func CreateCommit(baseBranch string, commitBranch string, gitopsPath string, files []string, commitMsg string) {
100+
func CreateCommit(baseBranch string, commitBranch string, gitopsPath string, files []string, prTitle string, prDescription string) {
101101
ctx := context.Background()
102102
gh := createGithubClient()
103103

@@ -117,8 +117,8 @@ func CreateCommit(baseBranch string, commitBranch string, gitopsPath string, fil
117117
log.Fatalf("failed to create tree: %v", err)
118118
}
119119

120-
pushCommit(ctx, gh, ref, tree, commitMsg)
121-
createPR(ctx, gh, baseBranch, commitBranch, commitMsg, "")
120+
pushCommit(ctx, gh, ref, tree, prTitle)
121+
createPR(ctx, gh, baseBranch, commitBranch, prTitle, prDescription)
122122
}
123123

124124
func getFilesToCommit(gitopsPath string, inputPaths []string) ([]FileEntry, error) {

gitops/prer/create_gitops_prs.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,22 @@ func main() {
320320
processImages(updatedTargets, cfg)
321321

322322
if !cfg.DryRun {
323-
commitMsg := fmt.Sprintf("GitOps for release branch %s from %s commit %s\n",
324-
cfg.ReleaseBranch, cfg.BranchName, cfg.GitCommit)
323+
slug := os.Getenv("BUILDKITE_PIPELINE_SLUG")
324+
url := os.Getenv("BUILDKITE_BUILD_URL")
325+
repo := os.Getenv("BUILDKITE_REPO")
326+
sha := os.Getenv("BUILDKITE_COMMIT")
327+
repo = strings.Replace(repo, ":", "/", 1)
328+
repo = strings.Replace(repo, "git@", "https://", 1)
329+
repo = strings.Replace(repo, ".git", "", 1)
330+
commit := fmt.Sprintf("%s/commit/%s", repo, sha)
331+
shortSha := sha[:7]
332+
333+
prTitle := fmt.Sprintf("Gitops Deploy: %s - %s", slug, shortSha)
334+
prDescription := fmt.Sprintf("Automated PR for [%s](%s) via [Buildkite Pipeline](%s)", slug, commit, url)
325335

326336
switch cfg.GitHost {
327337
case "github_app":
328-
github_app.CreateCommit(cfg.PRTargetBranch, cfg.BranchName, gitopsDir, modifiedFiles, commitMsg)
338+
github_app.CreateCommit(cfg.PRTargetBranch, cfg.BranchName, gitopsDir, modifiedFiles, prTitle, prDescription)
329339
return
330340
default:
331341
workdir.Push(updatedBranches)

0 commit comments

Comments
 (0)