@@ -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
@@ -1071,17 +1133,25 @@ module.exports = require("assert");
1071
1133
1072
1134
"use strict" ;
1073
1135
1136
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
1137
+ if ( mod && mod . __esModule ) return mod ;
1138
+ var result = { } ;
1139
+ if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
1140
+ result [ "default" ] = mod ;
1141
+ return result ;
1142
+ } ;
1074
1143
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1075
- const os = __webpack_require__ ( 87 ) ;
1144
+ const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1145
+ const utils_1 = __webpack_require__ ( 82 ) ;
1076
1146
/**
1077
1147
* Commands
1078
1148
*
1079
1149
* Command Format:
1080
- * ##[ name key=value; key=value] message
1150
+ * :: name key=value, key=value:: message
1081
1151
*
1082
1152
* Examples:
1083
- * ##[ warning] This is the user warning message
1084
- * ##[ set-secret name=mypassword]definitelyNotAPassword!
1153
+ * :: warning:: This is the message
1154
+ * :: set-env name=MY_VAR::some value
1085
1155
*/
1086
1156
function issueCommand ( command , properties , message ) {
1087
1157
const cmd = new Command ( command , properties , message ) ;
@@ -1106,34 +1176,39 @@ class Command {
1106
1176
let cmdStr = CMD_STRING + this . command ;
1107
1177
if ( this . properties && Object . keys ( this . properties ) . length > 0 ) {
1108
1178
cmdStr += ' ' ;
1179
+ let first = true ;
1109
1180
for ( const key in this . properties ) {
1110
1181
if ( this . properties . hasOwnProperty ( key ) ) {
1111
1182
const val = this . properties [ key ] ;
1112
1183
if ( val ) {
1113
- // safely append the val - avoid blowing up when attempting to
1114
- // call .replace() if message is not a string for some reason
1115
- cmdStr += `${ key } =${ escape ( `${ val || '' } ` ) } ,` ;
1184
+ if ( first ) {
1185
+ first = false ;
1186
+ }
1187
+ else {
1188
+ cmdStr += ',' ;
1189
+ }
1190
+ cmdStr += `${ key } =${ escapeProperty ( val ) } ` ;
1116
1191
}
1117
1192
}
1118
1193
}
1119
1194
}
1120
- cmdStr += CMD_STRING ;
1121
- // safely append the message - avoid blowing up when attempting to
1122
- // call .replace() if message is not a string for some reason
1123
- const message = `${ this . message || '' } ` ;
1124
- cmdStr += escapeData ( message ) ;
1195
+ cmdStr += `${ CMD_STRING } ${ escapeData ( this . message ) } ` ;
1125
1196
return cmdStr ;
1126
1197
}
1127
1198
}
1128
1199
function escapeData ( s ) {
1129
- return s . replace ( / \r / g, '%0D' ) . replace ( / \n / g, '%0A' ) ;
1200
+ return utils_1 . toCommandValue ( s )
1201
+ . replace ( / % / g, '%25' )
1202
+ . replace ( / \r / g, '%0D' )
1203
+ . replace ( / \n / g, '%0A' ) ;
1130
1204
}
1131
- function escape ( s ) {
1132
- return s
1205
+ function escapeProperty ( s ) {
1206
+ return utils_1 . toCommandValue ( s )
1207
+ . replace ( / % / g, '%25' )
1133
1208
. replace ( / \r / g, '%0D' )
1134
1209
. replace ( / \n / g, '%0A' )
1135
- . replace ( / ] / g, '%5D ' )
1136
- . replace ( / ; / g, '%3B ' ) ;
1210
+ . replace ( / : / g, '%3A ' )
1211
+ . replace ( / , / g, '%2C ' ) ;
1137
1212
}
1138
1213
//# sourceMappingURL=command.js.map
1139
1214
@@ -1153,10 +1228,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
1153
1228
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
1154
1229
} ) ;
1155
1230
} ;
1231
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
1232
+ if ( mod && mod . __esModule ) return mod ;
1233
+ var result = { } ;
1234
+ if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
1235
+ result [ "default" ] = mod ;
1236
+ return result ;
1237
+ } ;
1156
1238
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1157
1239
const command_1 = __webpack_require__ ( 431 ) ;
1158
- const os = __webpack_require__ ( 87 ) ;
1159
- const path = __webpack_require__ ( 622 ) ;
1240
+ const file_command_1 = __webpack_require__ ( 102 ) ;
1241
+ const utils_1 = __webpack_require__ ( 82 ) ;
1242
+ const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1243
+ const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1160
1244
/**
1161
1245
* The code to exit an action
1162
1246
*/
@@ -1177,11 +1261,21 @@ var ExitCode;
1177
1261
/**
1178
1262
* Sets env variable for this action and future actions in the job
1179
1263
* @param name the name of the variable to set
1180
- * @param val the value of the variable
1264
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
1181
1265
*/
1266
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1182
1267
function exportVariable ( name , val ) {
1183
- process . env [ name ] = val ;
1184
- command_1 . issueCommand ( 'set-env' , { name } , val ) ;
1268
+ const convertedVal = utils_1 . toCommandValue ( val ) ;
1269
+ process . env [ name ] = convertedVal ;
1270
+ const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
1271
+ if ( filePath ) {
1272
+ const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
1273
+ const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
1274
+ file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
1275
+ }
1276
+ else {
1277
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
1278
+ }
1185
1279
}
1186
1280
exports . exportVariable = exportVariable ;
1187
1281
/**
@@ -1197,7 +1291,13 @@ exports.setSecret = setSecret;
1197
1291
* @param inputPath
1198
1292
*/
1199
1293
function addPath ( inputPath ) {
1200
- command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
1294
+ const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
1295
+ if ( filePath ) {
1296
+ file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
1297
+ }
1298
+ else {
1299
+ command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
1300
+ }
1201
1301
process . env [ 'PATH' ] = `${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
1202
1302
}
1203
1303
exports . addPath = addPath ;
@@ -1220,12 +1320,22 @@ exports.getInput = getInput;
1220
1320
* Sets the value of an output.
1221
1321
*
1222
1322
* @param name name of the output to set
1223
- * @param value value to store
1323
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1224
1324
*/
1325
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1225
1326
function setOutput ( name , value ) {
1226
1327
command_1 . issueCommand ( 'set-output' , { name } , value ) ;
1227
1328
}
1228
1329
exports . setOutput = setOutput ;
1330
+ /**
1331
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
1332
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
1333
+ *
1334
+ */
1335
+ function setCommandEcho ( enabled ) {
1336
+ command_1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
1337
+ }
1338
+ exports . setCommandEcho = setCommandEcho ;
1229
1339
//-----------------------------------------------------------------------
1230
1340
// Results
1231
1341
//-----------------------------------------------------------------------
@@ -1242,6 +1352,13 @@ exports.setFailed = setFailed;
1242
1352
//-----------------------------------------------------------------------
1243
1353
// Logging Commands
1244
1354
//-----------------------------------------------------------------------
1355
+ /**
1356
+ * Gets whether Actions Step Debug is on or not
1357
+ */
1358
+ function isDebug ( ) {
1359
+ return process . env [ 'RUNNER_DEBUG' ] === '1' ;
1360
+ }
1361
+ exports . isDebug = isDebug ;
1245
1362
/**
1246
1363
* Writes debug message to user log
1247
1364
* @param message debug message
@@ -1252,18 +1369,18 @@ function debug(message) {
1252
1369
exports . debug = debug ;
1253
1370
/**
1254
1371
* Adds an error issue
1255
- * @param message error issue message
1372
+ * @param message error issue message. Errors will be converted to string via toString()
1256
1373
*/
1257
1374
function error ( message ) {
1258
- command_1 . issue ( 'error' , message ) ;
1375
+ command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
1259
1376
}
1260
1377
exports . error = error ;
1261
1378
/**
1262
1379
* Adds an warning issue
1263
- * @param message warning issue message
1380
+ * @param message warning issue message. Errors will be converted to string via toString()
1264
1381
*/
1265
1382
function warning ( message ) {
1266
- command_1 . issue ( 'warning' , message ) ;
1383
+ command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
1267
1384
}
1268
1385
exports . warning = warning ;
1269
1386
/**
@@ -1321,8 +1438,9 @@ exports.group = group;
1321
1438
* Saves state for current action, the state can only be retrieved by this action's post job execution.
1322
1439
*
1323
1440
* @param name name of the state to store
1324
- * @param value value to store
1441
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
1325
1442
*/
1443
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1326
1444
function saveState ( name , value ) {
1327
1445
command_1 . issueCommand ( 'save-state' , { name } , value ) ;
1328
1446
}
0 commit comments