diff --git a/dist/index.js b/dist/index.js index 9ed6a9cc7..b11a3b224 100644 --- a/dist/index.js +++ b/dist/index.js @@ -416,10 +416,15 @@ function getIDToken(aud) { } exports.getIDToken = getIDToken; /** - * Markdown summary exports + * Summary exports */ -var markdown_summary_1 = __nccwpck_require__(58042); -Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return markdown_summary_1.markdownSummary; } })); +var summary_1 = __nccwpck_require__(81327); +Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); +/** + * @deprecated use core.summary + */ +var summary_2 = __nccwpck_require__(81327); +Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); //# sourceMappingURL=core.js.map /***/ }), @@ -473,7 +478,91 @@ exports.issueCommand = issueCommand; /***/ }), -/***/ 58042: +/***/ 98041: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.OidcClient = void 0; +const http_client_1 = __nccwpck_require__(39925); +const auth_1 = __nccwpck_require__(23702); +const core_1 = __nccwpck_require__(42186); +class OidcClient { + static createHttpClient(allowRetry = true, maxRetry = 10) { + const requestOptions = { + allowRetries: allowRetry, + maxRetries: maxRetry + }; + return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); + } + static getRequestToken() { + const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; + if (!token) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); + } + return token; + } + static getIDTokenUrl() { + const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; + if (!runtimeUrl) { + throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); + } + return runtimeUrl; + } + static getCall(id_token_url) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const httpclient = OidcClient.createHttpClient(); + const res = yield httpclient + .getJson(id_token_url) + .catch(error => { + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n + Error Message: ${error.result.message}`); + }); + const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; + if (!id_token) { + throw new Error('Response json body do not have ID Token field'); + } + return id_token; + }); + } + static getIDToken(audience) { + return __awaiter(this, void 0, void 0, function* () { + try { + // New ID Token is requested from action service + let id_token_url = OidcClient.getIDTokenUrl(); + if (audience) { + const encodedAudience = encodeURIComponent(audience); + id_token_url = `${id_token_url}&audience=${encodedAudience}`; + } + core_1.debug(`ID token url is ${id_token_url}`); + const id_token = yield OidcClient.getCall(id_token_url); + core_1.setSecret(id_token); + return id_token; + } + catch (error) { + throw new Error(`Error message: ${error.message}`); + } + }); + } +} +exports.OidcClient = OidcClient; +//# sourceMappingURL=oidc-utils.js.map + +/***/ }), + +/***/ 81327: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -488,13 +577,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; +exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; const os_1 = __nccwpck_require__(22037); const fs_1 = __nccwpck_require__(57147); const { access, appendFile, writeFile } = fs_1.promises; exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; -exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary'; -class MarkdownSummary { +exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; +class Summary { constructor() { this._buffer = ''; } @@ -511,7 +600,7 @@ class MarkdownSummary { } const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; if (!pathFromEnv) { - throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports markdown summaries.`); + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); } try { yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); @@ -546,7 +635,7 @@ class MarkdownSummary { * * @param {SummaryWriteOptions} [options] (optional) options for write operation * - * @returns {Promise} markdown summary instance + * @returns {Promise} summary instance */ write(options) { return __awaiter(this, void 0, void 0, function* () { @@ -560,7 +649,7 @@ class MarkdownSummary { /** * Clears the summary buffer and wipes the summary file * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ clear() { return __awaiter(this, void 0, void 0, function* () { @@ -586,7 +675,7 @@ class MarkdownSummary { /** * Resets the summary buffer without writing to summary file * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ emptyBuffer() { this._buffer = ''; @@ -598,7 +687,7 @@ class MarkdownSummary { * @param {string} text content to add * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addRaw(text, addEOL = false) { this._buffer += text; @@ -607,7 +696,7 @@ class MarkdownSummary { /** * Adds the operating system-specific end-of-line marker to the buffer * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addEOL() { return this.addRaw(os_1.EOL); @@ -618,7 +707,7 @@ class MarkdownSummary { * @param {string} code content to render within fenced code block * @param {string} lang (optional) language to syntax highlight code * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addCodeBlock(code, lang) { const attrs = Object.assign({}, (lang && { lang })); @@ -631,7 +720,7 @@ class MarkdownSummary { * @param {string[]} items list of items to render * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addList(items, ordered = false) { const tag = ordered ? 'ol' : 'ul'; @@ -644,7 +733,7 @@ class MarkdownSummary { * * @param {SummaryTableCell[]} rows table rows * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addTable(rows) { const tableBody = rows @@ -672,7 +761,7 @@ class MarkdownSummary { * @param {string} label text for the closed state * @param {string} content collapsable content * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addDetails(label, content) { const element = this.wrap('details', this.wrap('summary', label) + content); @@ -685,7 +774,7 @@ class MarkdownSummary { * @param {string} alt text description of the image * @param {SummaryImageOptions} options (optional) addition image attributes * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addImage(src, alt, options) { const { width, height } = options || {}; @@ -699,7 +788,7 @@ class MarkdownSummary { * @param {string} text heading text * @param {number | string} [level=1] (optional) the heading level, default: 1 * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addHeading(text, level) { const tag = `h${level}`; @@ -712,7 +801,7 @@ class MarkdownSummary { /** * Adds an HTML thematic break (
) to the summary buffer * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addSeparator() { const element = this.wrap('hr', null); @@ -721,7 +810,7 @@ class MarkdownSummary { /** * Adds an HTML line break (
) to the summary buffer * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addBreak() { const element = this.wrap('br', null); @@ -733,7 +822,7 @@ class MarkdownSummary { * @param {string} text quote text * @param {string} cite (optional) citation url * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addQuote(text, cite) { const attrs = Object.assign({}, (cite && { cite })); @@ -746,100 +835,20 @@ class MarkdownSummary { * @param {string} text link text/content * @param {string} href hyperlink * - * @returns {MarkdownSummary} markdown summary instance + * @returns {Summary} summary instance */ addLink(text, href) { const element = this.wrap('a', text, { href }); return this.addRaw(element).addEOL(); } } -// singleton export -exports.markdownSummary = new MarkdownSummary(); -//# sourceMappingURL=markdown-summary.js.map - -/***/ }), - -/***/ 98041: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(39925); -const auth_1 = __nccwpck_require__(23702); -const core_1 = __nccwpck_require__(42186); -class OidcClient { - static createHttpClient(allowRetry = true, maxRetry = 10) { - const requestOptions = { - allowRetries: allowRetry, - maxRetries: maxRetry - }; - return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions); - } - static getRequestToken() { - const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']; - if (!token) { - throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'); - } - return token; - } - static getIDTokenUrl() { - const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']; - if (!runtimeUrl) { - throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable'); - } - return runtimeUrl; - } - static getCall(id_token_url) { - var _a; - return __awaiter(this, void 0, void 0, function* () { - const httpclient = OidcClient.createHttpClient(); - const res = yield httpclient - .getJson(id_token_url) - .catch(error => { - throw new Error(`Failed to get ID Token. \n - Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); - }); - const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; - if (!id_token) { - throw new Error('Response json body do not have ID Token field'); - } - return id_token; - }); - } - static getIDToken(audience) { - return __awaiter(this, void 0, void 0, function* () { - try { - // New ID Token is requested from action service - let id_token_url = OidcClient.getIDTokenUrl(); - if (audience) { - const encodedAudience = encodeURIComponent(audience); - id_token_url = `${id_token_url}&audience=${encodedAudience}`; - } - core_1.debug(`ID token url is ${id_token_url}`); - const id_token = yield OidcClient.getCall(id_token_url); - core_1.setSecret(id_token); - return id_token; - } - catch (error) { - throw new Error(`Error message: ${error.message}`); - } - }); - } -} -exports.OidcClient = OidcClient; -//# sourceMappingURL=oidc-utils.js.map +const _summary = new Summary(); +/** + * @deprecated use `core.summary` + */ +exports.markdownSummary = _summary; +exports.summary = _summary; +//# sourceMappingURL=summary.js.map /***/ }), diff --git a/package.json b/package.json index d8d1726e3..c104dc17e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "prepare": "husky install" }, "dependencies": { - "@actions/core": "1.7.0", + "@actions/core": "1.8.0", "@probot/adapter-github-actions": "3.1.1", "cli-table3": "0.6.2", "compare-versions": "4.1.3", diff --git a/yarn.lock b/yarn.lock index 7841ed496..2b7e3288e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@actions/core@1.7.0", "@actions/core@^1.2.6": - version "1.7.0" - resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.7.0.tgz#f179a5a0bf5c1102d89b8cf1712825e763feaee4" - integrity sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ== +"@actions/core@1.8.0", "@actions/core@^1.2.6": + version "1.8.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.8.0.tgz#5d98ff672b8ab73b718a939599c02f05c12755ad" + integrity sha512-XirM+Zo/PFlA+1h+i4bkfvagujta+LIM2AOSzPbt8JqXbbuxb1HTB+FqIyaKmue9yiCx/JIJY6pXsOl3+T8JGw== dependencies: "@actions/http-client" "^1.0.11"