@@ -328,14 +328,27 @@ run();
328
328
329
329
"use strict" ;
330
330
331
+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
332
+ if ( k2 === undefined ) k2 = k ;
333
+ Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
334
+ } ) : ( function ( o , m , k , k2 ) {
335
+ if ( k2 === undefined ) k2 = k ;
336
+ o [ k2 ] = m [ k ] ;
337
+ } ) ) ;
338
+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
339
+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
340
+ } ) : function ( o , v ) {
341
+ o [ "default" ] = v ;
342
+ } ) ;
331
343
var __importStar = ( this && this . __importStar ) || function ( mod ) {
332
344
if ( mod && mod . __esModule ) return mod ;
333
345
var result = { } ;
334
- if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
335
- result [ "default" ] = mod ;
346
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
347
+ __setModuleDefault ( result , mod ) ;
336
348
return result ;
337
349
} ;
338
350
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
351
+ exports . issue = exports . issueCommand = void 0 ;
339
352
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
340
353
const utils_1 = __nccwpck_require__ ( 5278 ) ;
341
354
/**
@@ -414,6 +427,25 @@ function escapeProperty(s) {
414
427
415
428
"use strict" ;
416
429
430
+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
431
+ if ( k2 === undefined ) k2 = k ;
432
+ Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
433
+ } ) : ( function ( o , m , k , k2 ) {
434
+ if ( k2 === undefined ) k2 = k ;
435
+ o [ k2 ] = m [ k ] ;
436
+ } ) ) ;
437
+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
438
+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
439
+ } ) : function ( o , v ) {
440
+ o [ "default" ] = v ;
441
+ } ) ;
442
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
443
+ if ( mod && mod . __esModule ) return mod ;
444
+ var result = { } ;
445
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
446
+ __setModuleDefault ( result , mod ) ;
447
+ return result ;
448
+ } ;
417
449
var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
418
450
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
419
451
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
@@ -423,19 +455,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
423
455
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
424
456
} ) ;
425
457
} ;
426
- var __importStar = ( this && this . __importStar ) || function ( mod ) {
427
- if ( mod && mod . __esModule ) return mod ;
428
- var result = { } ;
429
- if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
430
- result [ "default" ] = mod ;
431
- return result ;
432
- } ;
433
458
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
459
+ exports . getIDToken = exports . getState = exports . saveState = exports . group = exports . endGroup = exports . startGroup = exports . info = exports . notice = exports . warning = exports . error = exports . debug = exports . isDebug = exports . setFailed = exports . setCommandEcho = exports . setOutput = exports . getBooleanInput = exports . getMultilineInput = exports . getInput = exports . addPath = exports . setSecret = exports . exportVariable = exports . ExitCode = void 0 ;
434
460
const command_1 = __nccwpck_require__ ( 7351 ) ;
435
461
const file_command_1 = __nccwpck_require__ ( 717 ) ;
436
462
const utils_1 = __nccwpck_require__ ( 5278 ) ;
437
463
const os = __importStar ( __nccwpck_require__ ( 2037 ) ) ;
438
464
const path = __importStar ( __nccwpck_require__ ( 1017 ) ) ;
465
+ const oidc_utils_1 = __nccwpck_require__ ( 8041 ) ;
439
466
/**
440
467
* The code to exit an action
441
468
*/
@@ -497,7 +524,9 @@ function addPath(inputPath) {
497
524
}
498
525
exports . addPath = addPath ;
499
526
/**
500
- * Gets the value of an input. The value is also trimmed.
527
+ * Gets the value of an input.
528
+ * Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
529
+ * Returns an empty string if the value is not defined.
501
530
*
502
531
* @param name name of the input to get
503
532
* @param options optional. See InputOptions.
@@ -508,9 +537,49 @@ function getInput(name, options) {
508
537
if ( options && options . required && ! val ) {
509
538
throw new Error ( `Input required and not supplied: ${ name } ` ) ;
510
539
}
540
+ if ( options && options . trimWhitespace === false ) {
541
+ return val ;
542
+ }
511
543
return val . trim ( ) ;
512
544
}
513
545
exports . getInput = getInput ;
546
+ /**
547
+ * Gets the values of an multiline input. Each value is also trimmed.
548
+ *
549
+ * @param name name of the input to get
550
+ * @param options optional. See InputOptions.
551
+ * @returns string[]
552
+ *
553
+ */
554
+ function getMultilineInput ( name , options ) {
555
+ const inputs = getInput ( name , options )
556
+ . split ( '\n' )
557
+ . filter ( x => x !== '' ) ;
558
+ return inputs ;
559
+ }
560
+ exports . getMultilineInput = getMultilineInput ;
561
+ /**
562
+ * Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
563
+ * Support boolean input list: `true | True | TRUE | false | False | FALSE` .
564
+ * The return value is also in boolean type.
565
+ * ref: https://yaml.org/spec/1.2/spec.html#id2804923
566
+ *
567
+ * @param name name of the input to get
568
+ * @param options optional. See InputOptions.
569
+ * @returns boolean
570
+ */
571
+ function getBooleanInput ( name , options ) {
572
+ const trueValue = [ 'true' , 'True' , 'TRUE' ] ;
573
+ const falseValue = [ 'false' , 'False' , 'FALSE' ] ;
574
+ const val = getInput ( name , options ) ;
575
+ if ( trueValue . includes ( val ) )
576
+ return true ;
577
+ if ( falseValue . includes ( val ) )
578
+ return false ;
579
+ throw new TypeError ( `Input does not meet YAML 1.2 "Core Schema" specification: ${ name } \n` +
580
+ `Support boolean input list: \`true | True | TRUE | false | False | FALSE\`` ) ;
581
+ }
582
+ exports . getBooleanInput = getBooleanInput ;
514
583
/**
515
584
* Sets the value of an output.
516
585
*
@@ -519,6 +588,7 @@ exports.getInput = getInput;
519
588
*/
520
589
// eslint-disable-next-line @typescript-eslint/no-explicit-any
521
590
function setOutput ( name , value ) {
591
+ process . stdout . write ( os . EOL ) ;
522
592
command_1 . issueCommand ( 'set-output' , { name } , value ) ;
523
593
}
524
594
exports . setOutput = setOutput ;
@@ -565,19 +635,30 @@ exports.debug = debug;
565
635
/**
566
636
* Adds an error issue
567
637
* @param message error issue message. Errors will be converted to string via toString()
638
+ * @param properties optional properties to add to the annotation.
568
639
*/
569
- function error ( message ) {
570
- command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
640
+ function error ( message , properties = { } ) {
641
+ command_1 . issueCommand ( 'error' , utils_1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
571
642
}
572
643
exports . error = error ;
573
644
/**
574
- * Adds an warning issue
645
+ * Adds a warning issue
575
646
* @param message warning issue message. Errors will be converted to string via toString()
647
+ * @param properties optional properties to add to the annotation.
576
648
*/
577
- function warning ( message ) {
578
- command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
649
+ function warning ( message , properties = { } ) {
650
+ command_1 . issueCommand ( 'warning' , utils_1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
579
651
}
580
652
exports . warning = warning ;
653
+ /**
654
+ * Adds a notice issue
655
+ * @param message notice issue message. Errors will be converted to string via toString()
656
+ * @param properties optional properties to add to the annotation.
657
+ */
658
+ function notice ( message , properties = { } ) {
659
+ command_1 . issueCommand ( 'notice' , utils_1 . toCommandProperties ( properties ) , message instanceof Error ? message . toString ( ) : message ) ;
660
+ }
661
+ exports . notice = notice ;
581
662
/**
582
663
* Writes info to log with console.log.
583
664
* @param message info message
@@ -650,6 +731,12 @@ function getState(name) {
650
731
return process . env [ `STATE_${ name } ` ] || '' ;
651
732
}
652
733
exports . getState = getState ;
734
+ function getIDToken ( aud ) {
735
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
736
+ return yield oidc_utils_1 . OidcClient . getIDToken ( aud ) ;
737
+ } ) ;
738
+ }
739
+ exports . getIDToken = getIDToken ;
653
740
//# sourceMappingURL=core.js.map
654
741
655
742
/***/ } ) ,
@@ -660,14 +747,27 @@ exports.getState = getState;
660
747
"use strict" ;
661
748
662
749
// For internal use, subject to change.
750
+ var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
751
+ if ( k2 === undefined ) k2 = k ;
752
+ Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
753
+ } ) : ( function ( o , m , k , k2 ) {
754
+ if ( k2 === undefined ) k2 = k ;
755
+ o [ k2 ] = m [ k ] ;
756
+ } ) ) ;
757
+ var __setModuleDefault = ( this && this . __setModuleDefault ) || ( Object . create ? ( function ( o , v ) {
758
+ Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
759
+ } ) : function ( o , v ) {
760
+ o [ "default" ] = v ;
761
+ } ) ;
663
762
var __importStar = ( this && this . __importStar ) || function ( mod ) {
664
763
if ( mod && mod . __esModule ) return mod ;
665
764
var result = { } ;
666
- if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
667
- result [ "default" ] = mod ;
765
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
766
+ __setModuleDefault ( result , mod ) ;
668
767
return result ;
669
768
} ;
670
769
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
770
+ exports . issueCommand = void 0 ;
671
771
// We use any as a valid input type
672
772
/* eslint-disable @typescript-eslint/no-explicit-any */
673
773
const fs = __importStar ( __nccwpck_require__ ( 7147 ) ) ;
@@ -690,6 +790,90 @@ exports.issueCommand = issueCommand;
690
790
691
791
/***/ } ) ,
692
792
793
+ /***/ 8041 :
794
+ /***/ ( function ( __unused_webpack_module , exports , __nccwpck_require__ ) {
795
+
796
+ "use strict" ;
797
+
798
+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
799
+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
800
+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
801
+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
802
+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
803
+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
804
+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
805
+ } ) ;
806
+ } ;
807
+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
808
+ exports . OidcClient = void 0 ;
809
+ const http_client_1 = __nccwpck_require__ ( 9925 ) ;
810
+ const auth_1 = __nccwpck_require__ ( 3702 ) ;
811
+ const core_1 = __nccwpck_require__ ( 2186 ) ;
812
+ class OidcClient {
813
+ static createHttpClient ( allowRetry = true , maxRetry = 10 ) {
814
+ const requestOptions = {
815
+ allowRetries : allowRetry ,
816
+ maxRetries : maxRetry
817
+ } ;
818
+ return new http_client_1 . HttpClient ( 'actions/oidc-client' , [ new auth_1 . BearerCredentialHandler ( OidcClient . getRequestToken ( ) ) ] , requestOptions ) ;
819
+ }
820
+ static getRequestToken ( ) {
821
+ const token = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_TOKEN' ] ;
822
+ if ( ! token ) {
823
+ throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable' ) ;
824
+ }
825
+ return token ;
826
+ }
827
+ static getIDTokenUrl ( ) {
828
+ const runtimeUrl = process . env [ 'ACTIONS_ID_TOKEN_REQUEST_URL' ] ;
829
+ if ( ! runtimeUrl ) {
830
+ throw new Error ( 'Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable' ) ;
831
+ }
832
+ return runtimeUrl ;
833
+ }
834
+ static getCall ( id_token_url ) {
835
+ var _a ;
836
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
837
+ const httpclient = OidcClient . createHttpClient ( ) ;
838
+ const res = yield httpclient
839
+ . getJson ( id_token_url )
840
+ . catch ( error => {
841
+ throw new Error ( `Failed to get ID Token. \n
842
+ Error Code : ${ error . statusCode } \n
843
+ Error Message: ${ error . result . message } ` ) ;
844
+ } ) ;
845
+ const id_token = ( _a = res . result ) === null || _a === void 0 ? void 0 : _a . value ;
846
+ if ( ! id_token ) {
847
+ throw new Error ( 'Response json body do not have ID Token field' ) ;
848
+ }
849
+ return id_token ;
850
+ } ) ;
851
+ }
852
+ static getIDToken ( audience ) {
853
+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
854
+ try {
855
+ // New ID Token is requested from action service
856
+ let id_token_url = OidcClient . getIDTokenUrl ( ) ;
857
+ if ( audience ) {
858
+ const encodedAudience = encodeURIComponent ( audience ) ;
859
+ id_token_url = `${ id_token_url } &audience=${ encodedAudience } ` ;
860
+ }
861
+ core_1 . debug ( `ID token url is ${ id_token_url } ` ) ;
862
+ const id_token = yield OidcClient . getCall ( id_token_url ) ;
863
+ core_1 . setSecret ( id_token ) ;
864
+ return id_token ;
865
+ }
866
+ catch ( error ) {
867
+ throw new Error ( `Error message: ${ error . message } ` ) ;
868
+ }
869
+ } ) ;
870
+ }
871
+ }
872
+ exports . OidcClient = OidcClient ;
873
+ //# sourceMappingURL=oidc-utils.js.map
874
+
875
+ /***/ } ) ,
876
+
693
877
/***/ 5278 :
694
878
/***/ ( ( __unused_webpack_module , exports ) => {
695
879
@@ -698,6 +882,7 @@ exports.issueCommand = issueCommand;
698
882
// We use any as a valid input type
699
883
/* eslint-disable @typescript-eslint/no-explicit-any */
700
884
Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
885
+ exports . toCommandProperties = exports . toCommandValue = void 0 ;
701
886
/**
702
887
* Sanitizes an input into a string so it can be passed into issueCommand safely
703
888
* @param input input to sanitize into a string
@@ -712,6 +897,26 @@ function toCommandValue(input) {
712
897
return JSON . stringify ( input ) ;
713
898
}
714
899
exports . toCommandValue = toCommandValue ;
900
+ /**
901
+ *
902
+ * @param annotationProperties
903
+ * @returns The command properties to send with the actual annotation command
904
+ * See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
905
+ */
906
+ function toCommandProperties ( annotationProperties ) {
907
+ if ( ! Object . keys ( annotationProperties ) . length ) {
908
+ return { } ;
909
+ }
910
+ return {
911
+ title : annotationProperties . title ,
912
+ file : annotationProperties . file ,
913
+ line : annotationProperties . startLine ,
914
+ endLine : annotationProperties . endLine ,
915
+ col : annotationProperties . startColumn ,
916
+ endColumn : annotationProperties . endColumn
917
+ } ;
918
+ }
919
+ exports . toCommandProperties = toCommandProperties ;
715
920
//# sourceMappingURL=utils.js.map
716
921
717
922
/***/ } ) ,
0 commit comments