@@ -934,13 +934,75 @@ class ExecState extends events.EventEmitter {
934934
935935/***/ } ) ,
936936
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+
937963/***/ 87 :
938964/***/ ( function ( module ) {
939965
940966module . exports = require ( "os" ) ;
941967
942968/***/ } ) ,
943969
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+
9441006/***/ 129 :
9451007/***/ ( function ( module ) {
9461008
@@ -1082,6 +1144,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
10821144} ;
10831145Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
10841146const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1147+ const utils_1 = __webpack_require__ ( 82 ) ;
10851148/**
10861149 * Commands
10871150 *
@@ -1136,13 +1199,13 @@ class Command {
11361199 }
11371200}
11381201function escapeData ( s ) {
1139- return ( s || '' )
1202+ return utils_1 . toCommandValue ( s )
11401203 . replace ( / % / g, '%25' )
11411204 . replace ( / \r / g, '%0D' )
11421205 . replace ( / \n / g, '%0A' ) ;
11431206}
11441207function escapeProperty ( s ) {
1145- return ( s || '' )
1208+ return utils_1 . toCommandValue ( s )
11461209 . replace ( / % / g, '%25' )
11471210 . replace ( / \r / g, '%0D' )
11481211 . replace ( / \n / g, '%0A' )
@@ -1176,6 +1239,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
11761239} ;
11771240Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
11781241const command_1 = __webpack_require__ ( 431 ) ;
1242+ const file_command_1 = __webpack_require__ ( 102 ) ;
1243+ const utils_1 = __webpack_require__ ( 82 ) ;
11791244const os = __importStar ( __webpack_require__ ( 87 ) ) ;
11801245const path = __importStar ( __webpack_require__ ( 622 ) ) ;
11811246/**
@@ -1198,11 +1263,21 @@ var ExitCode;
11981263/**
11991264 * Sets env variable for this action and future actions in the job
12001265 * @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
12021267 */
1268+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12031269function 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+ }
12061281}
12071282exports . exportVariable = exportVariable ;
12081283/**
@@ -1218,7 +1293,13 @@ exports.setSecret = setSecret;
12181293 * @param inputPath
12191294 */
12201295function 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+ }
12221303 process . env [ 'PATH' ] = `${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
12231304}
12241305exports . addPath = addPath ;
@@ -1241,12 +1322,22 @@ exports.getInput = getInput;
12411322 * Sets the value of an output.
12421323 *
12431324 * @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
12451326 */
1327+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12461328function setOutput ( name , value ) {
12471329 command_1 . issueCommand ( 'set-output' , { name } , value ) ;
12481330}
12491331exports . 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 ;
12501341//-----------------------------------------------------------------------
12511342// Results
12521343//-----------------------------------------------------------------------
@@ -1263,6 +1354,13 @@ exports.setFailed = setFailed;
12631354//-----------------------------------------------------------------------
12641355// Logging Commands
12651356//-----------------------------------------------------------------------
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 ;
12661364/**
12671365 * Writes debug message to user log
12681366 * @param message debug message
@@ -1273,18 +1371,18 @@ function debug(message) {
12731371exports . debug = debug ;
12741372/**
12751373 * Adds an error issue
1276- * @param message error issue message
1374+ * @param message error issue message. Errors will be converted to string via toString()
12771375 */
12781376function error ( message ) {
1279- command_1 . issue ( 'error' , message ) ;
1377+ command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
12801378}
12811379exports . error = error ;
12821380/**
12831381 * Adds an warning issue
1284- * @param message warning issue message
1382+ * @param message warning issue message. Errors will be converted to string via toString()
12851383 */
12861384function warning ( message ) {
1287- command_1 . issue ( 'warning' , message ) ;
1385+ command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
12881386}
12891387exports . warning = warning ;
12901388/**
@@ -1342,8 +1440,9 @@ exports.group = group;
13421440 * Saves state for current action, the state can only be retrieved by this action's post job execution.
13431441 *
13441442 * @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
13461444 */
1445+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13471446function saveState ( name , value ) {
13481447 command_1 . issueCommand ( 'save-state' , { name } , value ) ;
13491448}
0 commit comments