Skip to content

Commit

Permalink
Update subscription validation logic (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
varunsh-coder authored Nov 22, 2023
1 parent f069941 commit 8e5e38d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ jobs:
# Fix timestamps
- name: restore timestamps
uses: ./
with:
STEPSECURITY_API_KEY: ${{ secrets.STEPSECURITY_API_KEY }}

# Check timestamps
- name: validate
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ jobs:
# Fix timestamps
- name: restore timestamps
uses: step-security/git-restore-mtime-action@v1
with:
STEPSECURITY_API_KEY: ${{ secrets.STEPSECURITY_API_KEY }}

# Upload to S3
- name: sync s3
Expand Down
23 changes: 16 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ description: "Restore file's modified time (timestamp) based on git commits"
branding:
icon: "check-square"
color: "green"
inputs:
STEPSECURITY_API_KEY:
description: "API key for validation"
required: true
runs:
using: "composite"
steps:
- name: Validate API Key
- name: Validate subscription
shell: bash
run: |
# TODO: Validate API Key
echo "Invalid API Key"
API_URL="https://agent.api.stepsecurity.io/v1/github/$GITHUB_REPOSITORY/actions/subscription"
# Set a timeout for the curl command (3 seconds)
RESPONSE=$(curl --max-time 3 -s -w "%{http_code}" "$API_URL" -o /dev/null) || true
CURL_EXIT_CODE=${?}
# Check if the response code is not 200
if [ $CURL_EXIT_CODE -ne 0 ] || [ "$RESPONSE" != "200" ]; then
if [ -z "$RESPONSE" ] || [ "$RESPONSE" == "000" ] || [ $CURL_EXIT_CODE -ne 0 ]; then
echo "Timeout or API not reachable. Continuing to next step."
else
echo "Subscription is not valid. Reach out to [email protected]"
exit 1
fi
fi
- name: Run git-restore-mtime
shell: bash
Expand Down

0 comments on commit 8e5e38d

Please sign in to comment.