Skip to content

Commit

Permalink
Merge pull request #3361 from esl/mu-summary-commenter
Browse files Browse the repository at this point in the history
Comment failures to a separate issue
  • Loading branch information
NelsonVides committed Oct 25, 2021
2 parents 4109562 + 5980790 commit 5f82ff6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .circleci/config.yml
Expand Up @@ -165,6 +165,14 @@ commands:
when: always
command: |
tools/circle-publish-github-comment.sh
publish_github_summary_comment:
steps:
- run:
name: Publish a summary comment to GitHub
when: on_fail
command: |
tools/circle-publish-github-summary-comment.sh
maybe_prepare_minio:
steps:
- run:
Expand Down Expand Up @@ -344,6 +352,7 @@ jobs:
tail -100 _build/mim2/rel/mongooseim/log/mongooseim.log.1
- upload_results_to_aws
- publish_github_comment
- publish_github_summary_comment

# #########################
# jobs in docker containers
Expand Down
35 changes: 35 additions & 0 deletions tools/circle-publish-github-summary-comment.sh
@@ -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

0 comments on commit 5f82ff6

Please sign in to comment.