@@ -1243,6 +1243,32 @@ class SemVer {
1243
1243
module . exports = SemVer
1244
1244
1245
1245
1246
+ /***/ } ) ,
1247
+
1248
+ /***/ 82 :
1249
+ /***/ ( function ( __unusedmodule , exports ) {
1250
+
1251
+ "use strict" ;
1252
+
1253
+ // We use any as a valid input type
1254
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1255
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1256
+ /**
1257
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
1258
+ * @param input input to sanitize into a string
1259
+ */
1260
+ function toCommandValue ( input ) {
1261
+ if ( input === null || input === undefined ) {
1262
+ return '' ;
1263
+ }
1264
+ else if ( typeof input === 'string' || input instanceof String ) {
1265
+ return input ;
1266
+ }
1267
+ return JSON . stringify ( input ) ;
1268
+ }
1269
+ exports . toCommandValue = toCommandValue ;
1270
+ //# sourceMappingURL=utils.js.map
1271
+
1246
1272
/***/ } ) ,
1247
1273
1248
1274
/***/ 87 :
@@ -1252,6 +1278,42 @@ module.exports = require("os");
1252
1278
1253
1279
/***/ } ) ,
1254
1280
1281
+ /***/ 102 :
1282
+ /***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
1283
+
1284
+ "use strict" ;
1285
+
1286
+ // For internal use, subject to change.
1287
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
1288
+ if ( mod && mod . __esModule ) return mod ;
1289
+ var result = { } ;
1290
+ if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
1291
+ result [ "default" ] = mod ;
1292
+ return result ;
1293
+ } ;
1294
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1295
+ // We use any as a valid input type
1296
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1297
+ const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
1298
+ const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1299
+ const utils_1 = __webpack_require__ ( 82 ) ;
1300
+ function issueCommand ( command , message ) {
1301
+ const filePath = process . env [ `GITHUB_${ command } ` ] ;
1302
+ if ( ! filePath ) {
1303
+ throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
1304
+ }
1305
+ if ( ! fs . existsSync ( filePath ) ) {
1306
+ throw new Error ( `Missing file at path: ${ filePath } ` ) ;
1307
+ }
1308
+ fs . appendFileSync ( filePath , `${ utils_1 . toCommandValue ( message ) } ${ os . EOL } ` , {
1309
+ encoding : 'utf8'
1310
+ } ) ;
1311
+ }
1312
+ exports . issueCommand = issueCommand ;
1313
+ //# sourceMappingURL=file-command.js.map
1314
+
1315
+ /***/ } ) ,
1316
+
1255
1317
/***/ 120 :
1256
1318
/***/ ( function ( module , __unusedexports , __webpack_require__ ) {
1257
1319
@@ -2422,6 +2484,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2422
2484
} ;
2423
2485
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2424
2486
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
2487
+ const utils_1 = __webpack_require__ ( 82 ) ;
2425
2488
/**
2426
2489
* Commands
2427
2490
*
@@ -2476,13 +2539,13 @@ class Command {
2476
2539
}
2477
2540
}
2478
2541
function escapeData ( s ) {
2479
- return ( s || '' )
2542
+ return utils_1 . toCommandValue ( s )
2480
2543
. replace ( / % / g, '%25' )
2481
2544
. replace ( / \r / g, '%0D' )
2482
2545
. replace ( / \n / g, '%0A' ) ;
2483
2546
}
2484
2547
function escapeProperty ( s ) {
2485
- return ( s || '' )
2548
+ return utils_1 . toCommandValue ( s )
2486
2549
. replace ( / % / g, '%25' )
2487
2550
. replace ( / \r / g, '%0D' )
2488
2551
. replace ( / \n / g, '%0A' )
@@ -2603,6 +2666,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
2603
2666
} ;
2604
2667
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
2605
2668
const command_1 = __webpack_require__ ( 431 ) ;
2669
+ const file_command_1 = __webpack_require__ ( 102 ) ;
2670
+ const utils_1 = __webpack_require__ ( 82 ) ;
2606
2671
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
2607
2672
const path = __importStar ( __webpack_require__ ( 622 ) ) ;
2608
2673
/**
@@ -2625,11 +2690,21 @@ var ExitCode;
2625
2690
/**
2626
2691
* Sets env variable for this action and future actions in the job
2627
2692
* @param name the name of the variable to set
2628
- * @param val the value of the variable
2693
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
2629
2694
*/
2695
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2630
2696
function exportVariable ( name , val ) {
2631
- process . env [ name ] = val ;
2632
- command_1 . issueCommand ( 'set-env' , { name } , val ) ;
2697
+ const convertedVal = utils_1 . toCommandValue ( val ) ;
2698
+ process . env [ name ] = convertedVal ;
2699
+ const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
2700
+ if ( filePath ) {
2701
+ const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
2702
+ const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
2703
+ file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
2704
+ }
2705
+ else {
2706
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
2707
+ }
2633
2708
}
2634
2709
exports . exportVariable = exportVariable ;
2635
2710
/**
@@ -2645,7 +2720,13 @@ exports.setSecret = setSecret;
2645
2720
* @param inputPath
2646
2721
*/
2647
2722
function addPath ( inputPath ) {
2648
- command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
2723
+ const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
2724
+ if ( filePath ) {
2725
+ file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
2726
+ }
2727
+ else {
2728
+ command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
2729
+ }
2649
2730
process . env [ 'PATH' ] = `${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
2650
2731
}
2651
2732
exports . addPath = addPath ;
@@ -2668,12 +2749,22 @@ exports.getInput = getInput;
2668
2749
* Sets the value of an output.
2669
2750
*
2670
2751
* @param name name of the output to set
2671
- * @param value value to store
2752
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
2672
2753
*/
2754
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2673
2755
function setOutput ( name , value ) {
2674
2756
command_1 . issueCommand ( 'set-output' , { name } , value ) ;
2675
2757
}
2676
2758
exports . setOutput = setOutput ;
2759
+ /**
2760
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
2761
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
2762
+ *
2763
+ */
2764
+ function setCommandEcho ( enabled ) {
2765
+ command_1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
2766
+ }
2767
+ exports . setCommandEcho = setCommandEcho ;
2677
2768
//-----------------------------------------------------------------------
2678
2769
// Results
2679
2770
//-----------------------------------------------------------------------
@@ -2707,18 +2798,18 @@ function debug(message) {
2707
2798
exports . debug = debug ;
2708
2799
/**
2709
2800
* Adds an error issue
2710
- * @param message error issue message
2801
+ * @param message error issue message. Errors will be converted to string via toString()
2711
2802
*/
2712
2803
function error ( message ) {
2713
- command_1 . issue ( 'error' , message ) ;
2804
+ command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
2714
2805
}
2715
2806
exports . error = error ;
2716
2807
/**
2717
2808
* Adds an warning issue
2718
- * @param message warning issue message
2809
+ * @param message warning issue message. Errors will be converted to string via toString()
2719
2810
*/
2720
2811
function warning ( message ) {
2721
- command_1 . issue ( 'warning' , message ) ;
2812
+ command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
2722
2813
}
2723
2814
exports . warning = warning ;
2724
2815
/**
@@ -2776,8 +2867,9 @@ exports.group = group;
2776
2867
* Saves state for current action, the state can only be retrieved by this action's post job execution.
2777
2868
*
2778
2869
* @param name name of the state to store
2779
- * @param value value to store
2870
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
2780
2871
*/
2872
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2781
2873
function saveState ( name , value ) {
2782
2874
command_1 . issueCommand ( 'save-state' , { name } , value ) ;
2783
2875
}
0 commit comments