From ab8564d4c58474664b0b30a6957c078f16905c84 Mon Sep 17 00:00:00 2001 From: Rohan Khandelwal <98796241+rohankh532@users.noreply.github.com> Date: Thu, 28 Apr 2022 10:59:50 -0700 Subject: [PATCH] Log repo_info.json File in entrypoint.sh (#211) * test action * log repo_json file * check status >=300 * log json * fixed conditional * fixed or * fixed or * spacing * remove file before exit * always print repo_info --- entrypoint.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index c176cf5a..7cf17489 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -47,11 +47,18 @@ export ENABLED_CHECKS= # # Boolean inputs are strings https://github.com/actions/runner/issues/1483. # =============================================================================== -curl -s -H "Authorization: Bearer $GITHUB_AUTH_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY > repo_info.json +status_code=$(curl -s -H "Authorization: Bearer $GITHUB_AUTH_TOKEN" https://api.github.com/repos/"$GITHUB_REPOSITORY" -o repo_info.json -w '%{http_code}') +if [[ $status_code -lt 200 ]] || [[ $status_code -ge 300 ]]; then + error_msg=$(jq -r .message repo_info.json 2>/dev/null || echo 'unknown error') + echo "Failed to get repository information from GitHub, response $status_code: $error_msg" + echo "$(