Skip to content

Commit

Permalink
Replace spaces in traceId
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenraad Verheyden committed Aug 26, 2020
1 parent fcca366 commit f0db288
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.randomInt = exports.getTimestamp = exports.setEnv = exports.getEnv = void 0;
exports.replaceSpaces = exports.randomInt = exports.getTimestamp = exports.setEnv = exports.getEnv = void 0;
const core = __importStar(__webpack_require__(470));
function getEnv(name) {
return process.env[name];
Expand All @@ -1543,6 +1543,10 @@ function randomInt(max) {
return Math.trunc(Math.random() * max);
}
exports.randomInt = randomInt;
function replaceSpaces(str) {
return str.replace(/\s+/g, '_');
}
exports.replaceSpaces = replaceSpaces;


/***/ }),
Expand Down Expand Up @@ -2105,7 +2109,7 @@ function run() {
core.debug(`- ${key} = ${process.env[key]}`);
}
const buildStart = util.getTimestamp();
const traceId = `${util.getEnv('GITHUB_WORKFLOW')}-${util.getEnv('GITHUB_JOB')}-${util.getEnv('GITHUB_RUN_NUMBER')}`;
const traceId = util.replaceSpaces(`${util.getEnv('GITHUB_WORKFLOW')}-${util.getEnv('GITHUB_JOB')}-${util.getEnv('GITHUB_RUN_NUMBER')}`);
// save buildStart to be used in the post section
core.saveState('buildStart', buildStart.toString());
const apikey = core.getInput('apikey', { required: true });
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ async function run(): Promise<void> {
}

const buildStart = util.getTimestamp()
const traceId = `${util.getEnv('GITHUB_WORKFLOW')}-${util.getEnv('GITHUB_JOB')}-${util.getEnv('GITHUB_RUN_NUMBER')}`
const traceId = util.replaceSpaces(
`${util.getEnv('GITHUB_WORKFLOW')}-${util.getEnv('GITHUB_JOB')}-${util.getEnv('GITHUB_RUN_NUMBER')}`
)

// save buildStart to be used in the post section
core.saveState('buildStart', buildStart.toString())
Expand Down
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ export function getTimestamp(): number {
export function randomInt(max: number): number {
return Math.trunc(Math.random() * max)
}

export function replaceSpaces(str: string): string {
return str.replace(/\s+/g, '_')
}

0 comments on commit f0db288

Please sign in to comment.