Skip to content

Commit db8b4ec

Browse files
Merge pull request #61 from step-security/feat/update-subscription-check
feat: added banner and update subscription check to make maintained actions free for public repos
2 parents 0d1df42 + f6cfa0b commit db8b4ec

4 files changed

Lines changed: 42 additions & 18 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ENV RELEASE_NOTE_GENERATOR_VERSION="v0.0.12"
99
ENV RELEASE_NOTE_GENERATOR_CHECKSUM="f42a5b90e3b3cc02c74d289b36af36c317c71d4be67d86f575cc3a853d9e3c7e"
1010

1111
COPY *.sh /
12-
RUN apk add --no-cache curl && \
12+
RUN apk add --no-cache curl jq && \
1313
chmod +x JSON.sh && \
1414
wget -O github-release-notes-generator.jar https://github.com/spring-io/github-changelog-generator/releases/download/${RELEASE_NOTE_GENERATOR_VERSION}/github-changelog-generator.jar && \
1515
echo "$RELEASE_NOTE_GENERATOR_CHECKSUM github-release-notes-generator.jar" | sha256sum -c -

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright (c) 2023 StepSecurity
189+
Copyright (c) 2026 StepSecurity
190190
Copyright 2019 Decathlon
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![StepSecurity Maintained Action](https://raw.githubusercontent.com/step-security/maintained-actions-assets/main/assets/maintained-action-banner.png)](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions)
2+
13
<h1>
24
<p align="center">
35
Release Note Generator GitHub Action

entrypoint.sh

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,44 @@ OWNER_ID=$(/JSON.sh < "${GITHUB_EVENT_PATH}" | grep '\["repository","owner","log
1111
GH_USERNAME=$(/JSON.sh < "${GITHUB_EVENT_PATH}" | grep '\["sender","login"]' | cut -f2 | sed 's/\"//g')
1212
PROVIDED_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
3052
fi
3153

3254
MILESTONE_ID_TO_USE=${MILESTONE_NUMBER:-$PROVIDED_MILESTONE_ID}

0 commit comments

Comments
 (0)