diff --git a/start-mongodb.sh b/start-mongodb.sh index b4748ce..94d62e8 100644 --- a/start-mongodb.sh +++ b/start-mongodb.sh @@ -15,16 +15,18 @@ API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/ # Set a timeout for the curl command (3 seconds) RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" "$API_URL" -o /dev/null) || true -CURL_EXIT_CODE=${?} - -# Check if the response code is not 200 -if [ $CURL_EXIT_CODE -ne 0 ] || [ "$RESPONSE" != "200" ]; then - if [ -z "$RESPONSE" ] || [ "$RESPONSE" == "000" ] || [ $CURL_EXIT_CODE -ne 0 ]; then - echo "Timeout or API not reachable. Continuing to next step." - else - echo "Subscription is not valid. Reach out to support@stepsecurity.io" - exit 1 - fi +CURL_EXIT_CODE=$? + +# Decide based on curl exit code and HTTP status +if [ $CURL_EXIT_CODE -ne 0 ]; then + echo "Timeout or API not reachable. Continuing to next step." +elif [ "$RESPONSE" = "200" ]; then + : +elif [ "$RESPONSE" = "403" ]; then + echo "Subscription is not valid. Reach out to support@stepsecurity.io" + exit 1 +else + echo "Timeout or API not reachable. Continuing to next step." fi # `mongosh` is used starting from MongoDB 5.x