Skip to content

Commit cc7dd80

Browse files
qfenq
1 parent b831dfb commit cc7dd80

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/main.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,43 +70,44 @@ const oidcWarning =
7070
async function validateSubscription() {
7171
const actionName = process.env.GITHUB_ACTION_REPOSITORY || 'step-security/google-github-auth';
7272

73-
// Log maintained action info with formatting and colors
74-
core.info('');
75-
core.info(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
76-
core.info(chalk.bold.white(' 📦 StepSecurity Maintained Action'));
77-
core.info('');
78-
core.info(chalk.gray(' Action: ') + chalk.cyan.bold(actionName));
79-
core.info(chalk.gray(' Status: ') + chalk.green('Free for public repositories'));
80-
core.info(chalk.gray(' Docs: ') + chalk.yellow('https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions'));
81-
core.info(chalk.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
73+
// Banner
8274
core.info('');
75+
core.info(chalk.bold.yellow('StepSecurity Maintained Action'));
76+
core.info(`Secure, reviewed, drop-in replacement for ${actionName}`);
8377

8478
const repoPrivate = github.context?.payload?.repository?.private;
8579

8680
if (repoPrivate === false) {
87-
core.info('Repository is public, skipping subscription validation.');
81+
core.info(chalk.green('\u2713 Free for public repositories'));
82+
}
83+
84+
core.info(chalk.cyan('Learn more: ') + 'https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions');
85+
core.info('');
86+
87+
if (repoPrivate === false) {
8888
return;
8989
}
9090

91-
const [owner, repo] = (process.env.GITHUB_REPOSITORY || '').split('/');
91+
const apiUrl = `https://int.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`;
9292
const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com';
93-
const body: Record<string, string> = {};
94-
if (process.env.GITHUB_ACTION_REPOSITORY) body.action = process.env.GITHUB_ACTION_REPOSITORY;
95-
if (serverUrl !== 'https://github.com') body.ghes_server = serverUrl;
9693

97-
const url = `https://int.api.stepsecurity.io/v1/github/${owner}/${repo}/actions/maintained-actions-subscription`;
98-
core.info(`POST ${url}`);
94+
const body: Record<string, string> = {
95+
action: process.env.GITHUB_ACTION_REPOSITORY || '',
96+
};
97+
if (serverUrl !== 'https://github.com') {
98+
body.ghes_server = serverUrl;
99+
}
100+
101+
core.info(`POST ${apiUrl}`);
99102
core.info(`Request body: ${JSON.stringify(body)}`);
100103

101104
try {
102-
await axios.post(url, body, { timeout: 3000 });
105+
await axios.post(apiUrl, body, { timeout: 3000 });
103106
} catch (error) {
104107
if (isAxiosError(error) && error.response?.status === 403) {
105108
core.error(
106-
'This StepSecurity maintained action is free for public repositories.\n' +
107-
'This repository is private and does not currently have a StepSecurity Enterprise subscription enabled, so the action was not executed.\n\n' +
108-
'Learn more:\n' +
109-
'https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions'
109+
'This action requires a StepSecurity subscription for private repositories.\n' +
110+
'Learn how to enable a subscription: https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions'
110111
);
111112
process.exit(1);
112113
}

0 commit comments

Comments
 (0)