Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3361 from esl/mu-summary-commenter
Comment failures to a separate issue
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ ! -f /tmp/ct_summary ]] ; then | ||
echo 'File "/tmp/ct_summary" is not there, aborting.' | ||
exit | ||
fi | ||
|
||
if [ -z "$COMMENTER_GITHUB_TOKEN" ]; then | ||
echo "\$COMMENTER_GITHUB_TOKEN is empty. Do nothing" | ||
exit 0 | ||
fi | ||
|
||
function make_body | ||
{ | ||
echo "[Build]($CIRCLE_BUILD_URL) on $CIRCLE_BRANCH" | ||
if [ ! -z "$CIRCLE_PULL_REQUEST" ]; then | ||
echo "PR $CIRCLE_PULL_REQUEST" | ||
fi | ||
cat /tmp/ct_summary | ||
} | ||
|
||
REPO_SLUG="$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" | ||
|
||
function post_new_comment | ||
{ | ||
POST_BODY=$(BODY_ENV="$BODY" jq -n '{body: env.BODY_ENV}') | ||
curl -v -o /dev/null -i \ | ||
-H "Authorization: token $COMMENTER_GITHUB_TOKEN" \ | ||
-H "Content-Type: application/json" \ | ||
-X POST -d "$POST_BODY" \ | ||
https://api.github.com/repos/$REPO_SLUG/issues/3360/comments | ||
} | ||
|
||
BODY=$(make_body) | ||
post_new_comment |