From a8c441e5d246a57e9a3e03ee4ed38a150e363771 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 6 Jul 2021 08:42:54 -0400 Subject: [PATCH] Ask comment.sh not to check event type per #70 --- scripts/comment.sh | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/scripts/comment.sh b/scripts/comment.sh index 7b47ca0..be7b8f9 100755 --- a/scripts/comment.sh +++ b/scripts/comment.sh @@ -10,21 +10,27 @@ _planfile="${GITHUB_WORKSPACE}/octodns-sync.plan" if [ "${ADD_PR_COMMENT}" = "Yes" ]; then - echo "INFO: \$ADD_PR_COMMENT is 'Yes'." - if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then - if [ -z "${PR_COMMENT_TOKEN}" ]; then - echo "FAIL: \$PR_COMMENT_TOKEN is not set." - exit 1 - fi - else - echo "SKIP: \$GITHUB_EVENT_NAME is not 'pull_request'." - exit 0 + if [ -z "${PR_COMMENT_TOKEN}" ]; then + echo "FAIL: \$PR_COMMENT_TOKEN is not set." + exit 1 fi - # Construct the comment body - _sha="$(git log -1 --format='%h')" - _header="## octoDNS Plan for ${_sha}" - _footer="Automatically generated by octodns-sync" - _body="${_header} + echo "INFO: \$ADD_PR_COMMENT is 'Yes' and \$PR_COMMENT_TOKEN is set." +else + echo "SKIP: \$ADD_PR_COMMENT is not 'Yes'." + exit 0 +fi + +if [ -z "${COMMENTS_URL}" ]; then + echo "SKIP: \$COMMENTS_URL is not set." + echo "Was this workflow run triggered from a pull request?" + exit 0 +fi + +# Construct the comment body +_sha="$(git log -1 --format='%h')" +_header="## octoDNS Plan for ${_sha}" +_footer="Automatically generated by octodns-sync" +_body="${_header} $(cat "${_planfile}") @@ -39,5 +45,3 @@ ${_footer}" comments_url = json.load(open(os.environ['GITHUB_EVENT_PATH'], 'r'))['pull_request']['comments_url'] response = requests.post(comments_url, auth=(os.environ['_user'], os.environ['_token']), json={'body':os.environ['_body']}) print(response)" - -fi