|
| 1 | +import require$$1 from 'fs'; |
1 | 2 | import require$$0$1 from 'os'; |
2 | 3 | import require$$0$2 from 'crypto'; |
3 | | -import require$$1 from 'fs'; |
4 | 4 | import require$$1$9, { resolve } from 'path'; |
5 | 5 | import require$$2$1 from 'http'; |
6 | 6 | import require$$1$1 from 'https'; |
@@ -81912,19 +81912,49 @@ async function run() { |
81912 | 81912 | } |
81913 | 81913 |
|
81914 | 81914 | async function validateSubscription() { |
81915 | | - const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`; |
| 81915 | + let repoPrivate; |
| 81916 | + const eventPath = process.env.GITHUB_EVENT_PATH; |
| 81917 | + if (eventPath && require$$1.existsSync(eventPath)) { |
| 81918 | + const payload = JSON.parse(require$$1.readFileSync(eventPath, 'utf8')); |
| 81919 | + repoPrivate = payload?.repository?.private; |
| 81920 | + } |
| 81921 | + |
| 81922 | + const upstream = 'amannn/action-semantic-pull-request'; |
| 81923 | + const action = process.env.GITHUB_ACTION_REPOSITORY; |
| 81924 | + const docsUrl = |
| 81925 | + 'https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions'; |
| 81926 | + |
| 81927 | + core.info(''); |
| 81928 | + core.info('\u001b[1;36mStepSecurity Maintained Action\u001b[0m'); |
| 81929 | + core.info(`Secure drop-in replacement for ${upstream}`); |
| 81930 | + if (repoPrivate === false) { |
| 81931 | + core.info('\u001b[32m\u2713 Free for public repositories\u001b[0m'); |
| 81932 | + } |
| 81933 | + core.info(`\u001b[36mLearn more:\u001b[0m ${docsUrl}`); |
| 81934 | + core.info(''); |
| 81935 | + |
| 81936 | + if (repoPrivate === false) return; |
| 81937 | + const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com'; |
| 81938 | + const body = {action: action || ''}; |
81916 | 81939 |
|
| 81940 | + if (serverUrl !== 'https://github.com') body.ghes_server = serverUrl; |
81917 | 81941 | try { |
81918 | | - await axios.get(API_URL, {timeout: 3000}); |
| 81942 | + await axios.post( |
| 81943 | + `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`, |
| 81944 | + body, |
| 81945 | + {timeout: 3000} |
| 81946 | + ); |
81919 | 81947 | } catch (error) { |
81920 | | - if (error.response && error.response.status === 403) { |
81921 | | - console.error( |
81922 | | - 'Subscription is not valid. Reach out to support@stepsecurity.io' |
| 81948 | + if (axios.isAxiosError(error) && error.response?.status === 403) { |
| 81949 | + core.error( |
| 81950 | + `\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m` |
| 81951 | + ); |
| 81952 | + core.error( |
| 81953 | + `\u001b[31mLearn how to enable a subscription: ${docsUrl}\u001b[0m` |
81923 | 81954 | ); |
81924 | 81955 | process.exit(1); |
81925 | | - } else { |
81926 | | - core.info('Timeout or API not reachable. Continuing to next step.'); |
81927 | 81956 | } |
| 81957 | + core.info('Timeout or API not reachable. Continuing to next step.'); |
81928 | 81958 | } |
81929 | 81959 | } |
81930 | 81960 |
|
|
0 commit comments