Skip to content

Commit

Permalink
Ask comment.sh not to check event type
Browse files Browse the repository at this point in the history
per #70
  • Loading branch information
solvaholic committed Jul 23, 2021
1 parent 10e1b88 commit a8c441e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions scripts/comment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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

0 comments on commit a8c441e

Please sign in to comment.