@@ -11,22 +11,44 @@ OWNER_ID=$(/JSON.sh < "${GITHUB_EVENT_PATH}" | grep '\["repository","owner","log
1111GH_USERNAME=$( /JSON.sh < " ${GITHUB_EVENT_PATH} " | grep ' \["sender","login"]' | cut -f2 | sed ' s/\"//g' )
1212PROVIDED_MILESTONE_ID=$( /JSON.sh < " ${GITHUB_EVENT_PATH} " | grep ' \["inputs","milestoneId"]' | cut -f2 | sed ' s/\"//g' )
1313
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- # Check if the response code is not 200
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+ REPO_PRIVATE=$( jq -r ' .repository.private | tostring' " $GITHUB_EVENT_PATH " 2> /dev/null || echo " " )
15+ UPSTREAM=" Decathlon/release-notes-generator-action"
16+ ACTION_REPO=" ${GITHUB_ACTION_REPOSITORY:- } "
17+ DOCS_URL=" https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"
18+
19+ echo " "
20+ echo -e " \033[1;36mStepSecurity Maintained Action\033[0m"
21+ echo " Secure drop-in replacement for $UPSTREAM "
22+ if [ " $REPO_PRIVATE " = " false" ]; then
23+ echo -e " \033[32m✓ Free for public repositories\033[0m"
24+ fi
25+ echo -e " \033[36mLearn more:\033[0m $DOCS_URL "
26+ echo " "
27+
28+ if [ " $REPO_PRIVATE " != " false" ]; then
29+ SERVER_URL=" ${GITHUB_SERVER_URL:- https:// github.com} "
30+
31+ if [ " $SERVER_URL " != " https://github.com" ]; then
32+ BODY=$( printf ' {"action":"%s","ghes_server":"%s"}' " $ACTION_REPO " " $SERVER_URL " )
33+ else
34+ BODY=$( printf ' {"action":"%s"}' " $ACTION_REPO " )
35+ fi
36+
37+ API_URL=" https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY /actions/maintained-actions-subscription"
38+
39+ RESPONSE=$( curl --max-time 3 -s -w " %{http_code}" \
40+ -X POST \
41+ -H " Content-Type: application/json" \
42+ -d " $BODY " \
43+ " $API_URL " -o /dev/null) && CURL_EXIT_CODE=0 || CURL_EXIT_CODE=$?
44+
45+ if [ $CURL_EXIT_CODE -ne 0 ]; then
46+ echo " Timeout or API not reachable. Continuing to next step."
47+ elif [ " $RESPONSE " = " 403" ]; then
48+ echo -e " ::error::\033[1;31mThis action requires a StepSecurity subscription for private repositories.\033[0m"
49+ echo -e " ::error::\033[31mLearn how to enable a subscription: $DOCS_URL \033[0m"
50+ exit 1
51+ fi
3052fi
3153
3254MILESTONE_ID_TO_USE=${MILESTONE_NUMBER:- $PROVIDED_MILESTONE_ID }
0 commit comments