@@ -4,50 +4,46 @@ import axios, { isAxiosError } from "axios";
44import { XcodeSelector } from "./xcode-selector" ;
55
66async function validateSubscription ( ) : Promise < void > {
7- const eventPath = process . env . GITHUB_EVENT_PATH
8- let repoPrivate : boolean | undefined
7+ const eventPath = process . env . GITHUB_EVENT_PATH ;
8+ let repoPrivate : boolean | undefined ;
99
10- if ( eventPath && fs . existsSync ( eventPath ) ) {
11- const eventData = JSON . parse ( fs . readFileSync ( eventPath , ' utf8' ) )
12- repoPrivate = eventData ?. repository ?. private
13- }
10+ if ( eventPath && fs . existsSync ( eventPath ) ) {
11+ const eventData = JSON . parse ( fs . readFileSync ( eventPath , " utf8" ) ) ;
12+ repoPrivate = eventData ?. repository ?. private ;
13+ }
1414
15- const upstream = 'maxim-lobanov/setup-xcode'
16- const action = process . env . GITHUB_ACTION_REPOSITORY
17- const docsUrl =
18- 'https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions'
15+ const upstream = "maxim-lobanov/setup-xcode" ;
16+ const action = process . env . GITHUB_ACTION_REPOSITORY ;
17+ const docsUrl = "https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions" ;
1918
20- core . info ( '' )
21- core . info ( '\u001b[1;36mStepSecurity Maintained Action\u001b[0m' )
22- core . info ( `Secure drop-in replacement for ${ upstream } ` )
23- if ( repoPrivate === false )
24- core . info ( '\u001b[32m\u2713 Free for public repositories\u001b[0m' )
25- core . info ( `\u001b[36mLearn more:\u001b[0m ${ docsUrl } ` )
26- core . info ( '' )
19+ core . info ( "" ) ;
20+ core . info ( "\u001b[1;36mStepSecurity Maintained Action\u001b[0m" ) ;
21+ core . info ( `Secure drop-in replacement for ${ upstream } ` ) ;
22+ if ( repoPrivate === false ) core . info ( "\u001b[32m\u2713 Free for public repositories\u001b[0m" ) ;
23+ core . info ( `\u001b[36mLearn more:\u001b[0m ${ docsUrl } ` ) ;
24+ core . info ( "" ) ;
2725
28- if ( repoPrivate === false ) return
26+ if ( repoPrivate === false ) return ;
2927
30- const serverUrl = process . env . GITHUB_SERVER_URL || ' https://github.com'
31- const body : Record < string , string > = { action : action || '' }
32- if ( serverUrl !== ' https://github.com' ) body . ghes_server = serverUrl
33- try {
34- await axios . post (
35- `https://agent.api.stepsecurity.io/v1/github/${ process . env . GITHUB_REPOSITORY } /actions/maintained-actions-subscription` ,
36- body ,
37- { timeout : 3000 }
38- )
39- } catch ( error ) {
40- if ( isAxiosError ( error ) && error . response ?. status === 403 ) {
41- core . error (
42- `\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m`
43- )
44- core . error (
45- `\u001b[31mLearn how to enable a subscription: ${ docsUrl } \u001b[0m`
46- )
47- process . exit ( 1 )
28+ const serverUrl = process . env . GITHUB_SERVER_URL || " https://github.com" ;
29+ const body : Record < string , string > = { action : action || "" } ;
30+ if ( serverUrl !== " https://github.com" ) body . ghes_server = serverUrl ;
31+ try {
32+ await axios . post (
33+ `https://agent.api.stepsecurity.io/v1/github/${ process . env . GITHUB_REPOSITORY } /actions/maintained-actions-subscription` ,
34+ body ,
35+ { timeout : 3000 } ,
36+ ) ;
37+ } catch ( error ) {
38+ if ( isAxiosError ( error ) && error . response ?. status === 403 ) {
39+ core . error (
40+ `\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m` ,
41+ ) ;
42+ core . error ( `\u001b[31mLearn how to enable a subscription: ${ docsUrl } \u001b[0m` ) ;
43+ process . exit ( 1 ) ;
44+ }
45+ core . info ( "Timeout or API not reachable. Continuing to next step." ) ;
4846 }
49- core . info ( 'Timeout or API not reachable. Continuing to next step.' )
50- }
5147}
5248
5349async function run ( ) : Promise < void > {
0 commit comments