From 6022bd2ee65953a6512136f08b20b94d12d107bb Mon Sep 17 00:00:00 2001 From: Lucas Gravley <29484535+admiralAwkbar@users.noreply.github.com> Date: Tue, 21 Jul 2020 10:13:15 -0500 Subject: [PATCH] Adding logic to skip status without proper data --- lib/linter.sh | 53 ++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/lib/linter.sh b/lib/linter.sh index 287ad6db..e2ec4321 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -826,32 +826,37 @@ CallStatusAPI() { MESSAGE="$FAIL_MSG" fi - ############################################## - # Call the status API to create status check # - ############################################## - SEND_STATUS_CMD=$(curl -f -s -X POST \ - --url "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ - -H 'accept: application/vnd.github.v3+json' \ - -H "authorization: Bearer $GITHUB_TOKEN" \ - -H 'content-type: application/json' \ - -d "{ \"state\": \"$STATUS\", - \"target_url\": \"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\", - \"description\": \"$MESSAGE\", \"context\": \"--> Linted: $LANGUAGE\" - }" 2>&1) + ########################################################## + # Check to see if were enabled for multi Status mesaages # + ########################################################## + if [ $MULTI_STATUS == "true" ]; then + ############################################## + # Call the status API to create status check # + ############################################## + SEND_STATUS_CMD=$(curl -f -s -X POST \ + --url "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/statuses/$GITHUB_SHA" \ + -H 'accept: application/vnd.github.v3+json' \ + -H "authorization: Bearer $GITHUB_TOKEN" \ + -H 'content-type: application/json' \ + -d "{ \"state\": \"$STATUS\", + \"target_url\": \"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\", + \"description\": \"$MESSAGE\", \"context\": \"--> Linted: $LANGUAGE\" + }" 2>&1) - ####################### - # Load the error code # - ####################### - ERROR_CODE=$? + ####################### + # Load the error code # + ####################### + ERROR_CODE=$? - ############################## - # Check the shell for errors # - ############################## - if [ "$ERROR_CODE" -ne 0 ]; then - # ERROR - echo "ERROR! Failed to call GitHub Status API!" - echo "ERROR:[$SEND_STATUS_CMD]" - # Not going to fail the script on this yet... + ############################## + # Check the shell for errors # + ############################## + if [ "$ERROR_CODE" -ne 0 ]; then + # ERROR + echo "ERROR! Failed to call GitHub Status API!" + echo "ERROR:[$SEND_STATUS_CMD]" + # Not going to fail the script on this yet... + fi fi } ################################################################################