Skip to content

Commit a04e95e

Browse files
committed
Repackage action after @actions/core bump
``` npm run build npm run pack ```
1 parent dc274a1 commit a04e95e

File tree

1 file changed

+222
-17
lines changed

1 file changed

+222
-17
lines changed

dist/index.js

+222-17
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,27 @@ run();
328328

329329
"use strict";
330330

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+
});
331343
var __importStar = (this && this.__importStar) || function (mod) {
332344
if (mod && mod.__esModule) return mod;
333345
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);
336348
return result;
337349
};
338350
Object.defineProperty(exports, "__esModule", ({ value: true }));
351+
exports.issue = exports.issueCommand = void 0;
339352
const os = __importStar(__nccwpck_require__(2037));
340353
const utils_1 = __nccwpck_require__(5278);
341354
/**
@@ -414,6 +427,25 @@ function escapeProperty(s) {
414427

415428
"use strict";
416429

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+
};
417449
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
418450
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
419451
return new (P || (P = Promise))(function (resolve, reject) {
@@ -423,19 +455,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
423455
step((generator = generator.apply(thisArg, _arguments || [])).next());
424456
});
425457
};
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-
};
433458
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;
434460
const command_1 = __nccwpck_require__(7351);
435461
const file_command_1 = __nccwpck_require__(717);
436462
const utils_1 = __nccwpck_require__(5278);
437463
const os = __importStar(__nccwpck_require__(2037));
438464
const path = __importStar(__nccwpck_require__(1017));
465+
const oidc_utils_1 = __nccwpck_require__(8041);
439466
/**
440467
* The code to exit an action
441468
*/
@@ -497,7 +524,9 @@ function addPath(inputPath) {
497524
}
498525
exports.addPath = addPath;
499526
/**
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.
501530
*
502531
* @param name name of the input to get
503532
* @param options optional. See InputOptions.
@@ -508,9 +537,49 @@ function getInput(name, options) {
508537
if (options && options.required && !val) {
509538
throw new Error(`Input required and not supplied: ${name}`);
510539
}
540+
if (options && options.trimWhitespace === false) {
541+
return val;
542+
}
511543
return val.trim();
512544
}
513545
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;
514583
/**
515584
* Sets the value of an output.
516585
*
@@ -519,6 +588,7 @@ exports.getInput = getInput;
519588
*/
520589
// eslint-disable-next-line @typescript-eslint/no-explicit-any
521590
function setOutput(name, value) {
591+
process.stdout.write(os.EOL);
522592
command_1.issueCommand('set-output', { name }, value);
523593
}
524594
exports.setOutput = setOutput;
@@ -565,19 +635,30 @@ exports.debug = debug;
565635
/**
566636
* Adds an error issue
567637
* @param message error issue message. Errors will be converted to string via toString()
638+
* @param properties optional properties to add to the annotation.
568639
*/
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);
571642
}
572643
exports.error = error;
573644
/**
574-
* Adds an warning issue
645+
* Adds a warning issue
575646
* @param message warning issue message. Errors will be converted to string via toString()
647+
* @param properties optional properties to add to the annotation.
576648
*/
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);
579651
}
580652
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;
581662
/**
582663
* Writes info to log with console.log.
583664
* @param message info message
@@ -650,6 +731,12 @@ function getState(name) {
650731
return process.env[`STATE_${name}`] || '';
651732
}
652733
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;
653740
//# sourceMappingURL=core.js.map
654741

655742
/***/ }),
@@ -660,14 +747,27 @@ exports.getState = getState;
660747
"use strict";
661748

662749
// 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+
});
663762
var __importStar = (this && this.__importStar) || function (mod) {
664763
if (mod && mod.__esModule) return mod;
665764
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);
668767
return result;
669768
};
670769
Object.defineProperty(exports, "__esModule", ({ value: true }));
770+
exports.issueCommand = void 0;
671771
// We use any as a valid input type
672772
/* eslint-disable @typescript-eslint/no-explicit-any */
673773
const fs = __importStar(__nccwpck_require__(7147));
@@ -690,6 +790,90 @@ exports.issueCommand = issueCommand;
690790

691791
/***/ }),
692792

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+
693877
/***/ 5278:
694878
/***/ ((__unused_webpack_module, exports) => {
695879

@@ -698,6 +882,7 @@ exports.issueCommand = issueCommand;
698882
// We use any as a valid input type
699883
/* eslint-disable @typescript-eslint/no-explicit-any */
700884
Object.defineProperty(exports, "__esModule", ({ value: true }));
885+
exports.toCommandProperties = exports.toCommandValue = void 0;
701886
/**
702887
* Sanitizes an input into a string so it can be passed into issueCommand safely
703888
* @param input input to sanitize into a string
@@ -712,6 +897,26 @@ function toCommandValue(input) {
712897
return JSON.stringify(input);
713898
}
714899
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;
715920
//# sourceMappingURL=utils.js.map
716921

717922
/***/ }),

0 commit comments

Comments
 (0)