Skip to content

Commit 943fb31

Browse files
committed
add warning for empty repo token
1 parent 2f01b56 commit 943fb31

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export SCORECARD_RESULTS_FORMAT="$INPUT_RESULTS_FORMAT"
3232
export SCORECARD_PUBLISH_RESULTS="$INPUT_PUBLISH_RESULTS"
3333
# https://docs.github.com/en/actions/learn-github-actions/environment-variables
3434
export SCORECARD_PRIVATE_REPOSITORY="$(jq '.repository.private' $GITHUB_EVENT_PATH)"
35+
export SCORECARD_IS_FORK="$(jq '.repository.fork' $GITHUB_EVENT_PATH)"
3536
export SCORECARD_BIN="/scorecard"
3637
export ENABLED_CHECKS=
3738

@@ -50,11 +51,25 @@ fi
5051
echo "Event file: $GITHUB_EVENT_PATH"
5152
echo "Event name: $GITHUB_EVENT_NAME"
5253
echo "Ref: $GITHUB_REF"
54+
echo "Fork repository: $SCORECARD_IS_FORK"
5355
echo "Private repository: $SCORECARD_PRIVATE_REPOSITORY"
5456
echo "Publication enabled: $SCORECARD_PUBLISH_RESULTS"
5557
echo "Format: $SCORECARD_RESULTS_FORMAT"
5658
echo "Policy file: $SCORECARD_POLICY_FILE"
5759

60+
if [[ -z "$GITHUB_AUTH_TOKEN" ]]; then
61+
echo "The 'repo_token' variable is empty."
62+
63+
if [[ "$SCORECARD_IS_FORK" == "true" ]]; then
64+
echo "We have detected you are running on a fork."
65+
fi
66+
67+
echo "Please follow the instructions at https://github.com/ossf/scorecard-action#authentication to create the read-only PAT token."
68+
exit 1
69+
fi
70+
71+
72+
5873
# Note: this will fail if we push to a branch on the same repo, so it will show as failing
5974
# on forked repos.
6075
if [[ "$GITHUB_EVENT_NAME" != "pull_request"* ]] && ! [[ "$GITHUB_REF" =~ ^refs/heads/(main|master)$ ]]; then

0 commit comments

Comments
 (0)