From d29b288cd3695aa295bb2bb832c904412755efa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Bra=C5=84ski?= Date: Fri, 28 Aug 2020 18:09:42 +0200 Subject: [PATCH] Added real comment to PR and reviewers --- templates/github-automated-workflow/Makefile.gotmpl | 13 +++++++------ templates/github-automated-workflow/workflow.yaml | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/templates/github-automated-workflow/Makefile.gotmpl b/templates/github-automated-workflow/Makefile.gotmpl index 8d34ad98..7a1298df 100644 --- a/templates/github-automated-workflow/Makefile.gotmpl +++ b/templates/github-automated-workflow/Makefile.gotmpl @@ -11,22 +11,23 @@ mp-plan: {{ if eq (ds "config").github.pr.enabled true -}} mp-push: echo Create PR - @mp push -b pr-body.md -a {{ (ds "config").github.pr.reviewer }} > log/mp_push.log + @mp push -b pr-body.md -a {{ index (ds "config").github.pr.reviewers 0 }} > log/mp_push.log {{- if ne (len (ds "config").github.pr.labels) 0 }} echo Label PR @echo '{"labels":["{{ join (ds "config").github.pr.labels "\",\"" }}"]}' > labels.json - echo 'LABELS_JSON=`cat labels.json`; cd {}; PR_NUMBER=`gh pr create 2>&1 | tail -n1 | sed "s#.*pull/##"`; echo $$LABELS_JSON | gh api -X PATCH repos/:owner/:repo/issues/$$PR_NUMBER --input -' @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'LABELS_JSON=`cat labels.json`; cd {}; PR_NUMBER=`gh pr create 2>&1 | tail -n1 | sed "s#.*pull/##"`; echo $$LABELS_JSON | gh api -X PATCH repos/:owner/:repo/issues/$$PR_NUMBER --input -' \; >> log/mp_push.log @rm labels.json {{- end }} - echo Add PR reviewers TODO - # https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request + echo Add PR reviewers + @echo '{"reviewers":["{{ join (ds "config").github.pr.reviewers "\",\"" }}"], "team_reviewers":["{{ join (ds "config").github.pr.team_reviewers "\",\"" }}"]}' > reviewers.json + @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'REVIEWERS_JSON=`cat reviewers.json`; cd {}; PR_NUMBER=`gh pr create 2>&1 | tail -n1 | sed "s#.*pull/##"`; echo $$REVIEWERS_JSON | gh api -X POST repos/:owner/:repo/pulls/$$PR_NUMBER/requested_reviewers --input -' \; >> log/mp_push.log + @rm reviewers.json {{ if eq (ds "config").tests true }} echo Run tests - @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'cd {}; gh pr review --comment -b "/test all"' \; + @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'cd {}; PR_NUMBER=`gh pr create 2>&1 | tail -n1 | sed "s#.*pull/##"`; gh api -X POST repos/:owner/:repo/issues/$$PR_NUMBER/comments -f body="/test all"' \; >> log/mp_push.log {{ end -}} {{ end }} @@ -36,5 +37,5 @@ status: {{ if eq (ds "config").tests true -}} # Run tests with `gh` command in planned repositories tests: - @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'cd {}; gh pr review --comment -b "/test all"' \; + @find . -name 'planned' -maxdepth 4 -type d -exec sh -c 'cd {}; PR_NUMBER=`gh pr create 2>&1 | tail -n1 | sed "s#.*pull/##"`; gh api -X POST repos/:owner/:repo/issues/$$PR_NUMBER/comments -f body="/test all"' \; >> log/mp_push.log {{ end -}} diff --git a/templates/github-automated-workflow/workflow.yaml b/templates/github-automated-workflow/workflow.yaml index 5148fe43..3861892c 100644 --- a/templates/github-automated-workflow/workflow.yaml +++ b/templates/github-automated-workflow/workflow.yaml @@ -16,8 +16,11 @@ github: - what why: - why - reviewer: 3h4x - # cloudposse/engineering + + reviewers: + - cloudpossebot + team_reviewers: + - terraform labels: - auto-merge