diff --git a/.circleci/config.yml b/.circleci/config.yml index 2041256a756..72b746f8879 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -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 diff --git a/tools/circle-publish-github-summary-comment.sh b/tools/circle-publish-github-summary-comment.sh new file mode 100755 index 00000000000..afd44a6acb8 --- /dev/null +++ b/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