@@ -934,13 +934,75 @@ class ExecState extends events.EventEmitter {
934
934
935
935
/***/ } ) ,
936
936
937
+ /***/ 82 :
938
+ /***/ ( function ( __unusedmodule , exports ) {
939
+
940
+ "use strict" ;
941
+
942
+ // We use any as a valid input type
943
+ /* eslint-disable @typescript-eslint/no-explicit-any */
944
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
945
+ /**
946
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
947
+ * @param input input to sanitize into a string
948
+ */
949
+ function toCommandValue ( input ) {
950
+ if ( input === null || input === undefined ) {
951
+ return '' ;
952
+ }
953
+ else if ( typeof input === 'string' || input instanceof String ) {
954
+ return input ;
955
+ }
956
+ return JSON . stringify ( input ) ;
957
+ }
958
+ exports . toCommandValue = toCommandValue ;
959
+ //# sourceMappingURL=utils.js.map
960
+
961
+ /***/ } ) ,
962
+
937
963
/***/ 87 :
938
964
/***/ ( function ( module ) {
939
965
940
966
module . exports = require ( "os" ) ;
941
967
942
968
/***/ } ) ,
943
969
970
+ /***/ 102 :
971
+ /***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
972
+
973
+ "use strict" ;
974
+
975
+ // For internal use, subject to change.
976
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
977
+ if ( mod && mod . __esModule ) return mod ;
978
+ var result = { } ;
979
+ if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
980
+ result [ "default" ] = mod ;
981
+ return result ;
982
+ } ;
983
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
984
+ // We use any as a valid input type
985
+ /* eslint-disable @typescript-eslint/no-explicit-any */
986
+ const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
987
+ const os = __importStar ( __webpack_require__ ( 87 ) ) ;
988
+ const utils_1 = __webpack_require__ ( 82 ) ;
989
+ function issueCommand ( command , message ) {
990
+ const filePath = process . env [ `GITHUB_${ command } ` ] ;
991
+ if ( ! filePath ) {
992
+ throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
993
+ }
994
+ if ( ! fs . existsSync ( filePath ) ) {
995
+ throw new Error ( `Missing file at path: ${ filePath } ` ) ;
996
+ }
997
+ fs . appendFileSync ( filePath , `${ utils_1 . toCommandValue ( message ) } ${ os . EOL } ` , {
998
+ encoding : 'utf8'
999
+ } ) ;
1000
+ }
1001
+ exports . issueCommand = issueCommand ;
1002
+ //# sourceMappingURL=file-command.js.map
1003
+
1004
+ /***/ } ) ,
1005
+
944
1006
/***/ 129 :
945
1007
/***/ ( function ( module ) {
946
1008
@@ -1082,6 +1144,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
1082
1144
} ;
1083
1145
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1084
1146
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1147
+ const utils_1 = __webpack_require__ ( 82 ) ;
1085
1148
/**
1086
1149
* Commands
1087
1150
*
@@ -1136,13 +1199,13 @@ class Command {
1136
1199
}
1137
1200
}
1138
1201
function escapeData ( s ) {
1139
- return ( s || '' )
1202
+ return utils_1 . toCommandValue ( s )
1140
1203
. replace ( / % / g, '%25' )
1141
1204
. replace ( / \r / g, '%0D' )
1142
1205
. replace ( / \n / g, '%0A' ) ;
1143
1206
}
1144
1207
function escapeProperty ( s ) {
1145
- return ( s || '' )
1208
+ return utils_1 . toCommandValue ( s )
1146
1209
. replace ( / % / g, '%25' )
1147
1210
. replace ( / \r / g, '%0D' )
1148
1211
. replace ( / \n / g, '%0A' )
@@ -1176,6 +1239,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
1176
1239
} ;
1177
1240
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1178
1241
const command_1 = __webpack_require__ ( 431 ) ;
1242
+ const file_command_1 = __webpack_require__ ( 102 ) ;
1243
+ const utils_1 = __webpack_require__ ( 82 ) ;
1179
1244
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1180
1245
const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1181
1246
/**
@@ -1198,11 +1263,21 @@ var ExitCode;
1198
1263
/**
1199
1264
* Sets env variable for this action and future actions in the job
1200
1265
* @param name the name of the variable to set
1201
- * @param val the value of the variable
1266
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
1202
1267
*/
1268
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1203
1269
function exportVariable ( name , val ) {
1204
- process . env [ name ] = val ;
1205
- command_1 . issueCommand ( 'set-env' , { name } , val ) ;
1270
+ const convertedVal = utils_1 . toCommandValue ( val ) ;
1271
+ process . env [ name ] = convertedVal ;
1272
+ const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
1273
+ if ( filePath ) {
1274
+ const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
1275
+ const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
1276
+ file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
1277
+ }
1278
+ else {
1279
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
1280
+ }
1206
1281
}
1207
1282
exports . exportVariable = exportVariable ;
1208
1283
/**
@@ -1218,7 +1293,13 @@ exports.setSecret = setSecret;
1218
1293
* @param inputPath
1219
1294
*/
1220
1295
function addPath ( inputPath ) {
1221
- command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
1296
+ const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
1297
+ if ( filePath ) {
1298
+ file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
1299
+ }
1300
+ else {
1301
+ command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
1302
+ }
1222
1303
process . env [ 'PATH' ] = `${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
1223
1304
}
1224
1305
exports . addPath = addPath ;
@@ -1241,12 +1322,22 @@ exports.getInput = getInput;
1241
1322
* Sets the value of an output.
1242
1323
*
1243
1324
* @param name name of the output to set
1244
- * @param value value to store
1325
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1245
1326
*/
1327
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1246
1328
function setOutput ( name , value ) {
1247
1329
command_1 . issueCommand ( 'set-output' , { name } , value ) ;
1248
1330
}
1249
1331
exports . setOutput = setOutput ;
1332
+ /**
1333
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
1334
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
1335
+ *
1336
+ */
1337
+ function setCommandEcho ( enabled ) {
1338
+ command_1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
1339
+ }
1340
+ exports . setCommandEcho = setCommandEcho ;
1250
1341
//-----------------------------------------------------------------------
1251
1342
// Results
1252
1343
//-----------------------------------------------------------------------
@@ -1263,6 +1354,13 @@ exports.setFailed = setFailed;
1263
1354
//-----------------------------------------------------------------------
1264
1355
// Logging Commands
1265
1356
//-----------------------------------------------------------------------
1357
+ /**
1358
+ * Gets whether Actions Step Debug is on or not
1359
+ */
1360
+ function isDebug ( ) {
1361
+ return process . env [ 'RUNNER_DEBUG' ] === '1' ;
1362
+ }
1363
+ exports . isDebug = isDebug ;
1266
1364
/**
1267
1365
* Writes debug message to user log
1268
1366
* @param message debug message
@@ -1273,18 +1371,18 @@ function debug(message) {
1273
1371
exports . debug = debug ;
1274
1372
/**
1275
1373
* Adds an error issue
1276
- * @param message error issue message
1374
+ * @param message error issue message. Errors will be converted to string via toString()
1277
1375
*/
1278
1376
function error ( message ) {
1279
- command_1 . issue ( 'error' , message ) ;
1377
+ command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
1280
1378
}
1281
1379
exports . error = error ;
1282
1380
/**
1283
1381
* Adds an warning issue
1284
- * @param message warning issue message
1382
+ * @param message warning issue message. Errors will be converted to string via toString()
1285
1383
*/
1286
1384
function warning ( message ) {
1287
- command_1 . issue ( 'warning' , message ) ;
1385
+ command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
1288
1386
}
1289
1387
exports . warning = warning ;
1290
1388
/**
@@ -1342,8 +1440,9 @@ exports.group = group;
1342
1440
* Saves state for current action, the state can only be retrieved by this action's post job execution.
1343
1441
*
1344
1442
* @param name name of the state to store
1345
- * @param value value to store
1443
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1346
1444
*/
1445
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1347
1446
function saveState ( name , value ) {
1348
1447
command_1 . issueCommand ( 'save-state' , { name } , value ) ;
1349
1448
}
0 commit comments