Skip to content

Commit

Permalink
[command] npm run release
Browse files Browse the repository at this point in the history
  • Loading branch information
8398a7 committed Jul 5, 2020
1 parent 07a5681 commit 540bda3
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions dist/index.js
Expand Up @@ -2297,8 +2297,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldFactory = void 0;
const github_1 = __webpack_require__(469);
class FieldFactory {
constructor(fields, github) {
constructor(fields, jobName, github) {
this.fields = fields.replace(/ /g, '').split(',');
this.jobName = jobName;
this.github = github;
}
includes(field) {
Expand All @@ -2322,6 +2323,9 @@ class FieldFactory {
this.includes('author')
? createAttachment('author', yield this.author())
: undefined,
this.includes('action')
? createAttachment('action', yield this.action())
: undefined,
this.includes('job')
? createAttachment('job', yield this.job())
: undefined,
Expand Down Expand Up @@ -2369,7 +2373,7 @@ class FieldFactory {
repo: github_1.context.repo.repo,
run_id: github_1.context.runId,
}));
const currentJob = resp === null || resp === void 0 ? void 0 : resp.data.jobs.find(job => job.name === github_1.context.job);
const currentJob = resp === null || resp === void 0 ? void 0 : resp.data.jobs.find(job => job.name === this.jobName);
let time = new Date().getTime() - new Date((_b = currentJob === null || currentJob === void 0 ? void 0 : currentJob.started_at) !== null && _b !== void 0 ? _b : '').getTime();
const h = Math.floor(time / (1000 * 60 * 60));
time -= h * 1000 * 60 * 60;
Expand Down Expand Up @@ -2399,8 +2403,8 @@ class FieldFactory {
repo: github_1.context.repo.repo,
run_id: github_1.context.runId,
}));
const jobId = (_b = resp === null || resp === void 0 ? void 0 : resp.data.jobs.find(job => job.name === github_1.context.job)) === null || _b === void 0 ? void 0 : _b.id;
const value = `<https://github.com/${owner}/${github_1.context.repo.repo}/runs/${jobId}|${github_1.context.job}>`;
const jobId = (_b = resp === null || resp === void 0 ? void 0 : resp.data.jobs.find(job => job.name === this.jobName)) === null || _b === void 0 ? void 0 : _b.id;
const value = `<https://github.com/${owner}/${github_1.context.repo.repo}/runs/${jobId}|${this.jobName}>`;
process.env.AS_JOB = value;
return value;
});
Expand Down Expand Up @@ -2446,6 +2450,16 @@ class FieldFactory {
return value;
});
}
action() {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const sha = (_b = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.sha) !== null && _b !== void 0 ? _b : github_1.context.sha;
const { owner, repo } = github_1.context.repo;
const value = `<https://github.com/${owner}/${repo}/commit/${sha}/checks|action>`;
process.env.AS_ACTION = value;
return value;
});
}
getCommit() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
Expand Down Expand Up @@ -10052,7 +10066,14 @@ class Client {
throw new Error('Specify secrets.SLACK_WEBHOOK_URL');
}
this.webhook = new webhook_1.IncomingWebhook(webhookUrl);
this.fieldFactory = new fields_1.FieldFactory(this.with.fields, this.github);
this.fieldFactory = new fields_1.FieldFactory(this.with.fields, this.jobName, this.github);
}
get jobName() {
if (process.env.MATRIX_CONTEXT == null ||
process.env.MATRIX_CONTEXT === 'null')
return github_1.context.job;
const os = JSON.parse(process.env.MATRIX_CONTEXT).os;
return os !== '' ? `${github_1.context.job} (${os})` : github_1.context.job;
}
success(text) {
return __awaiter(this, void 0, void 0, function* () {
Expand Down

0 comments on commit 540bda3

Please sign in to comment.