use ACTIONS_STEP_DEBUG to determine debug mode, use isTrueString lib function

This commit is contained in:
David Hiendl 2023-12-05 11:15:02 +01:00
parent adb7826676
commit cd3f3c67f2
4 changed files with 5865 additions and 2969 deletions

173
dist/index.js vendored
View File

@ -556,8 +556,8 @@ class OidcClient {
const res = yield httpclient
.getJson(id_token_url)
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
@ -30753,7 +30753,7 @@ module.exports = parseParams
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/
/******/ // The require function
/******/ function __nccwpck_require__(moduleId) {
/******/ // Check if module is in cache
@ -30767,7 +30767,7 @@ module.exports = parseParams
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
@ -30776,12 +30776,11 @@ module.exports = parseParams
/******/ } finally {
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
@ -30793,11 +30792,11 @@ module.exports = parseParams
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/
/******/ /* webpack/runtime/compat */
/******/
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
@ -30806,57 +30805,67 @@ var __webpack_exports__ = {};
// ESM COMPAT FLAG
__nccwpck_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
var github = __nccwpck_require__(5438);
// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
var github = __nccwpck_require__(5438);
// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
var core = __nccwpck_require__(2186);
;// CONCATENATED MODULE: external "process"
const external_process_namespaceObject = require("process");
;// CONCATENATED MODULE: ./src/lib.js
;// CONCATENATED MODULE: ./src/lib.js
function result_to_output(results) {
for (const key in results) {
if (!results.hasOwnProperty(key)) {
continue;
}
const value = results[key];
if (typeof value !== 'string') {
core.setOutput(key, JSON.stringify(value)); // TODO support nested objects with key chaining
}
else {
core.setOutput(key, value);
}
function result_to_output(results) {
for (const key in results) {
if (!results.hasOwnProperty(key)) {
continue;
}
const value = results[key];
if (typeof value !== 'string') {
core.setOutput(key, JSON.stringify(value)); // TODO support nested objects with key chaining
}
else {
core.setOutput(key, value);
}
}
}
;// CONCATENATED MODULE: ./src/collect_ci.js
function isTrueString(str) {
return str === '1'
|| str === 'true'
|| str === 'True'
|| str === 'TRUE';
}
;// CONCATENATED MODULE: ./src/collect_ci.js
function collect_ci(debug = false, output = false) {
const r = {
ci_hostname: false
};
try {
const url = new URL(github.context.serverUrl);
r.ci_hostname = url.hostname;
if (debug) {
console.log('results for collect_ci:', JSON.stringify(r, null, 2));
}
if (output) {
result_to_output(r);
}
return r;
function collect_ci(debug = false, output = false) {
const r = {
ci_hostname: false
};
try {
const url = new URL(github.context.serverUrl);
r.ci_hostname = url.hostname;
if (debug) {
console.log('results for collect_ci:', JSON.stringify(r, null, 2));
}
catch (error) {
console.log('partial results for collect_ci before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
external_process_namespaceObject.exit(1);
if (output) {
result_to_output(r);
}
return r;
}
catch (error) {
console.log('partial results for collect_ci before error: ', JSON.stringify(r, null, 2));
core.setFailed(error.message);
external_process_namespaceObject.exit(1);
}
}
;// CONCATENATED MODULE: ./node_modules/semver-parser/modules/common.js
/**
@ -31129,32 +31138,37 @@ const promises = {
*/
;// CONCATENATED MODULE: ./src/collect_git.js
;// CONCATENATED MODULE: ./src/collect_git.js
function collect_git(debug = false, output = false) {
function collect_git(debug = false, output = false) {
const r = {
git_is_branch : false,
git_is_tag : false,
git_is_pull_request: false,
git_current_branch: false,
git_ref_branch : false,
git_is_branch : false,
git_is_tag : false,
git_is_pull_request : false,
git_current_branch : false,
git_ref_branch : false,
git_is_default_branch: false,
git_tag : false,
semver_valid : false,
semver_major : false,
semver_minor : false,
semver_patch : false,
semver_build : false,
semver_pre : false
git_tag : false,
semver_valid : false,
semver_major : false,
semver_minor : false,
semver_patch : false,
semver_build : false,
semver_pre : false
};
try {
// TODO actually strip tag prefix
const stripTagPrefix = core.getInput('strip_tag_prefix');
r.git_is_tag = github.context.ref.startsWith('refs/tags/');
r.git_default_branch = github.context.payload?.repository?.defaultBranch;
r.git_is_tag = github.context.ref.startsWith('refs/tags/');
r.git_default_branch = github.context.payload?.repository?.defaultBranch;
r.git_is_pull_request = github.context.payload.pull_request != null;
if (r.git_is_pull_request) {
@ -31181,8 +31195,8 @@ const promises = {
'Failed to determine branch for non-PR and non-Tag action'
);
}
r.git_current_branch = github.context.ref.slice('refs/heads/'.length);
r.git_ref_branch = r.git_current_branch; // same as current branch for non-PR, non-Tag
r.git_current_branch = github.context.ref.slice('refs/heads/'.length);
r.git_ref_branch = r.git_current_branch; // same as current branch for non-PR, non-Tag
r.git_is_default_branch = r.git_current_branch == r.git_default_branch;
}
@ -31201,7 +31215,7 @@ const promises = {
r.semver_minor = parsed.minor;
r.semver_patch = parsed.patch;
r.semver_build = parsed.build;
r.semver_pre = parsed.pre;
r.semver_pre = parsed.pre;
}
}
else if (r.git_is_branch) {
@ -31216,7 +31230,7 @@ const promises = {
r.semver_minor = parsed.minor;
r.semver_patch = parsed.patch;
r.semver_build = parsed.build;
r.semver_pre = parsed.pre;
r.semver_pre = parsed.pre;
}
}
@ -31239,24 +31253,35 @@ const promises = {
;// CONCATENATED MODULE: ./src/index.js
function collect_all(debug = false, output = false) {
if (debug) {
console.log(JSON.stringify(github.context, null, 2));
}
collect_ci(debug, output);
collect_git(debug, output);
function collect_all(debug = false, output = false) {
if (debug) {
console.log(JSON.stringify(github.context, null, 2));
}
;// CONCATENATED MODULE: ./src/action.js
return {
...collect_ci(debug, output),
...collect_git(debug, output)
};
}
collect_all(true, true);
;// CONCATENATED MODULE: ./src/action.js
const debug = isTrueString(process.env['ACTIONS_STEP_DEBUG']);
collect_all(debug, true);
})();
module.exports = __webpack_exports__;
/******/ })()
;
;

8651
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
import {collect_all} from './index';
import {isTrueString} from './lib';
const debug = process.env['ACTIONS_STEP_DEBUG'] === '1' || process.env['ACTIONS_STEP_DEBUG'] === 'true';
const debug = isTrueString(process.env['ACTIONS_STEP_DEBUG']);
collect_all(debug, true);

View File

@ -14,3 +14,10 @@ export function result_to_output(results) {
}
}
}
export function isTrueString(str) {
return str === '1'
|| str === 'true'
|| str === 'True'
|| str === 'TRUE';
}