From f4b6d29fea6625bb5fbabf9ed6ac218e51f050cb Mon Sep 17 00:00:00 2001 From: amanstep Date: Tue, 24 Mar 2026 16:31:25 +0530 Subject: [PATCH] chore: added banner and new subscription check code --- .github/workflows/actions_release.yml | 7 ++++- .github/workflows/audit_package.yml | 5 +++ README.md | 2 ++ action.yml | 2 +- dist/index.js | 44 +++++++++++++++++++++------ src/run.js | 42 ++++++++++++++++++++----- 6 files changed, 83 insertions(+), 19 deletions(-) diff --git a/.github/workflows/actions_release.yml b/.github/workflows/actions_release.yml index c5f9e25..0321abf 100644 --- a/.github/workflows/actions_release.yml +++ b/.github/workflows/actions_release.yml @@ -6,6 +6,10 @@ on: tag: description: "Tag for the release" required: true + node_version: + description: "Specify Node.js version (e.g., '18', '20', 'lts/*')" + required: false + default: "24" permissions: contents: read @@ -18,4 +22,5 @@ jobs: uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1 with: - tag: "${{ github.event.inputs.tag }}" \ No newline at end of file + tag: "${{ github.event.inputs.tag }}" + node_version: "${{ github.event.inputs.node_version }}" \ No newline at end of file diff --git a/.github/workflows/audit_package.yml b/.github/workflows/audit_package.yml index 2cc740e..ae5e848 100644 --- a/.github/workflows/audit_package.yml +++ b/.github/workflows/audit_package.yml @@ -11,6 +11,10 @@ on: description: "Specify a base branch" required: false default: "main" + node_version: + description: "Specify Node.js version (e.g., '18', '20', 'lts/*')" + required: false + default: "24" schedule: - cron: "0 0 * * 1" @@ -20,6 +24,7 @@ jobs: with: force: ${{ inputs.force || false }} base_branch: ${{ inputs.base_branch || 'main' }} + node_version: ${{ inputs.node_version || '24' }} permissions: contents: write diff --git a/README.md b/README.md index b2b197c..2cc858b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![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) + # Setup starknet-class-hash action Downloads and installs the starknet-class-hash CLI tool for use in GitHub Actions workflows. diff --git a/action.yml b/action.yml index 14ce753..eb98ab1 100644 --- a/action.yml +++ b/action.yml @@ -6,5 +6,5 @@ inputs: description: Version of starknet-class-hash to install (e.g., '0.1.0' or 'v0.1.0') required: true runs: - using: "node20" + using: "node24" main: "dist/index.js" diff --git a/dist/index.js b/dist/index.js index ea063bd..0f31d47 100644 --- a/dist/index.js +++ b/dist/index.js @@ -39091,19 +39091,45 @@ async function locateInnerDirectory(parentPath) { const axios = __nccwpck_require__(7269) async function validateSubscription() { - const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription` - + let repoPrivate; + const eventPath = process.env.GITHUB_EVENT_PATH; + if (eventPath && fs.existsSync(eventPath)) { + const payload = JSON.parse(fs.readFileSync(eventPath, "utf8")); + repoPrivate = payload?.repository?.private; + } + + const upstream = "ericnordelo/setup-class-hash"; + const action = process.env.GITHUB_ACTION_REPOSITORY; + const docsUrl = + "https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"; + core.info(""); + core.info("\u001b[1;36mStepSecurity Maintained Action\u001b[0m"); + core.info(`Secure drop-in replacement for ${upstream}`); + if (repoPrivate === false) + core.info("\u001b[32m\u2713 Free for public repositories\u001b[0m"); + core.info(`\u001b[36mLearn more:\u001b[0m ${docsUrl}`); + core.info(""); + if (repoPrivate === false) return; + const serverUrl = process.env.GITHUB_SERVER_URL || "https://github.com"; + const body = { action: action || "" }; + if (serverUrl !== "https://github.com") body.ghes_server = serverUrl; try { - await axios.get(API_URL, {timeout: 3000}) + await axios.post( + `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`, + body, + { timeout: 3000 }, + ); } catch (error) { - if (error.response && error.response.status === 403) { + if (axios.isAxiosError(error) && error.response?.status === 403) { core.error( - 'Subscription is not valid. Reach out to support@stepsecurity.io' - ) - process.exit(1) - } else { - core.info('Timeout or API not reachable. Continuing to next step.') + `\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m`, + ); + core.error( + `\u001b[31mLearn how to enable a subscription: ${docsUrl}\u001b[0m`, + ); + process.exit(1); } + core.info("Timeout or API not reachable. Continuing to next step."); } } diff --git a/src/run.js b/src/run.js index 5e0872e..877994e 100644 --- a/src/run.js +++ b/src/run.js @@ -9,19 +9,45 @@ import { const axios = require("axios") async function validateSubscription() { - const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription` + let repoPrivate; + const eventPath = process.env.GITHUB_EVENT_PATH; + if (eventPath && fs.existsSync(eventPath)) { + const payload = JSON.parse(fs.readFileSync(eventPath, "utf8")); + repoPrivate = payload?.repository?.private; + } + const upstream = "ericnordelo/setup-class-hash"; + const action = process.env.GITHUB_ACTION_REPOSITORY; + const docsUrl = + "https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions"; + core.info(""); + core.info("\u001b[1;36mStepSecurity Maintained Action\u001b[0m"); + core.info(`Secure drop-in replacement for ${upstream}`); + if (repoPrivate === false) + core.info("\u001b[32m\u2713 Free for public repositories\u001b[0m"); + core.info(`\u001b[36mLearn more:\u001b[0m ${docsUrl}`); + core.info(""); + if (repoPrivate === false) return; + const serverUrl = process.env.GITHUB_SERVER_URL || "https://github.com"; + const body = { action: action || "" }; + if (serverUrl !== "https://github.com") body.ghes_server = serverUrl; try { - await axios.get(API_URL, {timeout: 3000}) + await axios.post( + `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`, + body, + { timeout: 3000 }, + ); } catch (error) { - if (error.response && error.response.status === 403) { + if (axios.isAxiosError(error) && error.response?.status === 403) { + core.error( + `\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m`, + ); core.error( - 'Subscription is not valid. Reach out to support@stepsecurity.io' - ) - process.exit(1) - } else { - core.info('Timeout or API not reachable. Continuing to next step.') + `\u001b[31mLearn how to enable a subscription: ${docsUrl}\u001b[0m`, + ); + process.exit(1); } + core.info("Timeout or API not reachable. Continuing to next step."); } }