@@ -11,24 +11,46 @@ MONGODB_PASSWORD=$7
1111MONGODB_CONTAINER_NAME=$8
1212
1313# validate subscription status
14- API_URL=" https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY /actions/subscription"
15-
16- # Set a timeout for the curl command (3 seconds)
17- RESPONSE=$( curl --max-time 3 -s -w " %{http_code}" " $API_URL " -o /dev/null) || true
18- CURL_EXIT_CODE=$?
19-
20- # Decide based on curl exit code and HTTP status
21- if [ $CURL_EXIT_CODE -ne 0 ]; then
22- echo " Timeout or API not reachable. Continuing to next step."
23- elif [ " $RESPONSE " = " 200" ]; then
24- :
25- elif [ " $RESPONSE " = " 403" ]; then
26- echo " Subscription is not valid. Reach out to support@stepsecurity.io"
27- exit 1
28- else
29- echo " Timeout or API not reachable. Continuing to next step."
14+ UPSTREAM=" supercharge/mongodb-github-action"
15+ ACTION_REPO=" ${GITHUB_ACTION_REPOSITORY:- } "
16+ DOCS_URL=" https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"
17+
18+ echo " "
19+ echo -e " \033[1;36mStepSecurity Maintained Action\033[0m"
20+ echo " Secure drop-in replacement for $UPSTREAM "
21+ if [ " $REPO_PRIVATE " = " false" ]; then
22+ echo -e " \033[32m✓ Free for public repositories\033[0m"
23+ fi
24+ echo -e " \033[36mLearn more:\033[0m $DOCS_URL "
25+ echo " "
26+
27+ if [ " $REPO_PRIVATE " = " true" ]; then
28+ SERVER_URL=" ${GITHUB_SERVER_URL:- https:// github.com} "
29+
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
35+
36+ API_URL=" https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY /actions/maintained-actions-subscription"
37+
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=$?
43+
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
3051fi
3152
53+
3254# `mongosh` is used starting from MongoDB 5.x
3355MONGODB_CLIENT=" mongosh --quiet"
3456
0 commit comments