@@ -11,24 +11,48 @@ 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"
14+ UPSTREAM=" supercharge/mongodb-github-action"
15+ ACTION_REPO=" ${GITHUB_ACTION_REPOSITORY:- } "
16+ DOCS_URL=" https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"
1517
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=$?
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+ exit 0
29+ fi
30+
31+ SERVER_URL=" ${GITHUB_SERVER_URL:- https:// github.com} "
32+
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
38+
39+ API_URL=" https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY /actions/maintained-actions-subscription"
40+
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=$?
1946
20- # Decide based on curl exit code and HTTP status
2147if [ $CURL_EXIT_CODE -ne 0 ]; then
2248 echo " Timeout or API not reachable. Continuing to next step."
23- elif [ " $RESPONSE " = " 200" ]; then
24- :
2549elif [ " $RESPONSE " = " 403" ]; then
26- echo " Subscription is not valid. Reach out to support@stepsecurity.io"
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"
2752 exit 1
28- else
29- echo " Timeout or API not reachable. Continuing to next step."
3053fi
3154
55+
3256# `mongosh` is used starting from MongoDB 5.x
3357MONGODB_CLIENT=" mongosh --quiet"
3458
0 commit comments