Skip to content

Commit bb1bf48

Browse files
committed
fix: improved subscription check code
1 parent 986ac14 commit bb1bf48

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

start-mongodb.sh

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,30 @@ fi
2424
echo -e "\033[36mLearn more:\033[0m $DOCS_URL"
2525
echo ""
2626

27-
if [ "$REPO_PRIVATE" != "true" ]; then
28-
exit 0
29-
fi
30-
31-
SERVER_URL="${GITHUB_SERVER_URL:-https://github.com}"
27+
if [ "$REPO_PRIVATE" = "true" ]; then
28+
SERVER_URL="${GITHUB_SERVER_URL:-https://github.com}"
3229

33-
if [ "$SERVER_URL" != "https://github.com" ]; then
34-
BODY=$(printf '{"action":"%s","ghes_server":"%s"}' "$ACTION_REPO" "$SERVER_URL")
35-
else
36-
BODY=$(printf '{"action":"%s"}' "$ACTION_REPO")
37-
fi
30+
if [ "$SERVER_URL" != "https://github.com" ]; then
31+
BODY=$(printf '{"action":"%s","ghes_server":"%s"}' "$ACTION_REPO" "$SERVER_URL")
32+
else
33+
BODY=$(printf '{"action":"%s"}' "$ACTION_REPO")
34+
fi
3835

39-
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/maintained-actions-subscription"
36+
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/maintained-actions-subscription"
4037

41-
RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" \
42-
-X POST \
43-
-H "Content-Type: application/json" \
44-
-d "$BODY" \
45-
"$API_URL" -o /dev/null) && CURL_EXIT_CODE=0 || CURL_EXIT_CODE=$?
38+
RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" \
39+
-X POST \
40+
-H "Content-Type: application/json" \
41+
-d "$BODY" \
42+
"$API_URL" -o /dev/null) && CURL_EXIT_CODE=0 || CURL_EXIT_CODE=$?
4643

47-
if [ $CURL_EXIT_CODE -ne 0 ]; then
48-
echo "Timeout or API not reachable. Continuing to next step."
49-
elif [ "$RESPONSE" = "403" ]; then
50-
echo -e "\033[1;31mThis action requires a StepSecurity subscription for private repositories.\033[0m"
51-
echo -e "\033[31mLearn how to enable a subscription: $DOCS_URL\033[0m"
52-
exit 1
44+
if [ $CURL_EXIT_CODE -ne 0 ]; then
45+
echo "Timeout or API not reachable. Continuing to next step."
46+
elif [ "$RESPONSE" = "403" ]; then
47+
echo -e "\033[1;31mThis action requires a StepSecurity subscription for private repositories.\033[0m"
48+
echo -e "\033[31mLearn how to enable a subscription: $DOCS_URL\033[0m"
49+
exit 1
50+
fi
5351
fi
5452

5553

0 commit comments

Comments
 (0)