Skip to content

Commit

Permalink
Log repo_info.json File in entrypoint.sh (#211)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rohankh532 committed Apr 28, 2022
1 parent 98a77f8 commit ab8564d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$(<repo_info.json)"
rm repo_info.json
exit 1;
fi

export SCORECARD_PRIVATE_REPOSITORY="$(cat repo_info.json | jq -r '.private')"
export SCORECARD_DEFAULT_BRANCH="refs/heads/$(cat repo_info.json | jq -r '.default_branch')"
export SCORECARD_IS_FORK="$(cat repo_info.json | jq -r '.fork')"
rm repo_info.json

# If the repository is private, never publish the results.
if [[ "$SCORECARD_PRIVATE_REPOSITORY" == "true" ]]; then
Expand All @@ -73,6 +80,8 @@ echo "Publication enabled: $SCORECARD_PUBLISH_RESULTS"
echo "Format: $SCORECARD_RESULTS_FORMAT"
echo "Policy file: $SCORECARD_POLICY_FILE"
echo "Default branch: $SCORECARD_DEFAULT_BRANCH"
echo "$(<repo_info.json)"
rm repo_info.json

if [[ -z "$GITHUB_AUTH_TOKEN" ]]; then
echo "The 'repo_token' variable is empty."
Expand Down

0 comments on commit ab8564d

Please sign in to comment.