Skip to content

Commit 3dd7c5e

Browse files
Merge pull request #55 from step-security/feat/update-subscription-check
feat: added banner and update subscription check to make maintained actions free for public repos
2 parents e5076bf + 741dace commit 3dd7c5e

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

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
# Slack Notify - GitHub Action
24
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
35

entrypoint.sh

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
#!/usr/bin/env bash
22

3-
# Validate subscription status
4-
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/subscription"
3+
REPO_PRIVATE=$(jq -r '.repository.private | tostring' "$GITHUB_EVENT_PATH" 2>/dev/null || echo "")
4+
UPSTREAM="rtCamp/action-slack-notify"
5+
ACTION_REPO="${GITHUB_ACTION_REPOSITORY:-}"
6+
DOCS_URL="https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"
57

6-
# Set a timeout for the curl command (3 seconds)
7-
RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" "$API_URL" -o /dev/null) || true
8-
CURL_EXIT_CODE=${?}
8+
echo ""
9+
echo -e "\033[1;36mStepSecurity Maintained Action\033[0m"
10+
echo "Secure drop-in replacement for $UPSTREAM"
11+
if [ "$REPO_PRIVATE" = "false" ]; then
12+
echo -e "\033[32m✓ Free for public repositories\033[0m"
13+
fi
14+
echo -e "\033[36mLearn more:\033[0m $DOCS_URL"
15+
echo ""
16+
17+
if [ "$REPO_PRIVATE" != "false" ]; then
18+
SERVER_URL="${GITHUB_SERVER_URL:-https://github.com}"
19+
20+
if [ "$SERVER_URL" != "https://github.com" ]; then
21+
BODY=$(printf '{"action":"%s","ghes_server":"%s"}' "$ACTION_REPO" "$SERVER_URL")
22+
else
23+
BODY=$(printf '{"action":"%s"}' "$ACTION_REPO")
24+
fi
925

10-
if [ $CURL_EXIT_CODE -ne 0 ]; then
11-
echo "Timeout or API not reachable. Continuing to next step."
12-
elif [ "$RESPONSE" = "200" ]; then
13-
:
14-
elif [ "$RESPONSE" = "403" ]; then
15-
echo "Subscription is not valid. Reach out to support@stepsecurity.io"
16-
exit 1
17-
else
18-
echo "Timeout or API not reachable. Continuing to next step."
26+
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/maintained-actions-subscription"
27+
28+
RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" \
29+
-X POST \
30+
-H "Content-Type: application/json" \
31+
-d "$BODY" \
32+
"$API_URL" -o /dev/null) && CURL_EXIT_CODE=0 || CURL_EXIT_CODE=$?
33+
34+
if [ $CURL_EXIT_CODE -ne 0 ]; then
35+
echo "Timeout or API not reachable. Continuing to next step."
36+
elif [ "$RESPONSE" = "403" ]; then
37+
echo -e "::error::\033[1;31mThis action requires a StepSecurity subscription for private repositories.\033[0m"
38+
echo -e "::error::\033[31mLearn how to enable a subscription: $DOCS_URL\033[0m"
39+
exit 1
40+
fi
1941
fi
2042

2143
# Check required env variables

0 commit comments

Comments
 (0)