Skip to content

Commit

Permalink
create msg on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
arcticfalcon committed Jul 27, 2023
1 parent 084f050 commit 67a403b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 33 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ outputs:
pre_release:
description: 'Whether it is a release candidate'
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
31 changes: 15 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12958,9 +12958,9 @@ function run() {
approved = true;
}
}
core.info(JSON.stringify(reviews.data));
if (!approved) {
core.setFailed('An approval is required to generate a release candidate.');
yield addComment(pr.number, `:warning: An approval is required to create a release candidate. :warning:`);
core.setFailed('An approval is required to create a release candidate.');
return;
}
yield createTag(pr);
Expand All @@ -12973,13 +12973,7 @@ function run() {
// Opened:
if (prPayload.action === 'opened') {
yield addLabel(prPayload.pull_request);
const params = {
repo,
issue_number: prPayload.number,
owner,
body: `Add a comment including \`#tag\` to create a release candidate tag.`
};
yield octokit.issues.createComment(params);
yield addComment(prPayload.number, `Add a comment including \`#tag\` to create a release candidate tag.`);
return;
}
// Continue only when PR is closed and merged:
Expand Down Expand Up @@ -13012,6 +13006,17 @@ function addLabel(pr) {
});
});
}
function addComment(prNumber, body) {
return __awaiter(this, void 0, void 0, function* () {
const params = {
repo,
issue_number: prNumber,
owner,
body
};
yield octokit.issues.createComment(params);
});
}
function bash(cmd) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(function (resolve, reject) {
Expand Down Expand Up @@ -13119,13 +13124,7 @@ function createTag(pr) {
core.setOutput("new_tag", newTag);
core.setOutput("pre_release", preRelease);
// Create comment
const params = {
repo,
issue_number: prNumber,
owner,
body: `:label: ${preRelease ? 'Pre-release' : 'Release'} \`${newTag}\` created. [See build.](https://circleci.com/gh/mercadolibre/${repo})`
};
const new_comment = yield octokit.issues.createComment(params);
yield addComment(prNumber, `:label: ${preRelease ? 'Pre-release' : 'Release'} \`${newTag}\` created. [See build.](https://circleci.com/gh/mercadolibre/${repo})`);
});
}
run();
Expand Down
30 changes: 14 additions & 16 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async function run() {
approved = true
}
}
core.info(JSON.stringify(reviews.data))
if(!approved) {
core.setFailed('An approval is required to generate a release candidate.');
await addComment(pr.number, `:warning: An approval is required to create a release candidate. :warning:`);
core.setFailed('An approval is required to create a release candidate.');
return
}

Expand All @@ -67,13 +67,7 @@ async function run() {
// Opened:
if (prPayload.action === 'opened') {
await addLabel(prPayload.pull_request)
const params = {
repo,
issue_number: prPayload.number,
owner,
body: `Add a comment including \`#tag\` to create a release candidate tag.`
};
await octokit.issues.createComment(params);
await addComment(prPayload.number, `Add a comment including \`#tag\` to create a release candidate tag.`)
return
}
// Continue only when PR is closed and merged:
Expand Down Expand Up @@ -104,6 +98,16 @@ async function addLabel(pr: WebhookPayloadPullRequestPullRequest) {
})
}

async function addComment(prNumber:number, body:string) {
const params = {
repo,
issue_number: prNumber,
owner,
body
};
await octokit.issues.createComment(params);
}

async function bash(cmd) {
return new Promise<{stdout: string, stderr:string}>(function (resolve, reject) {
exec(cmd, (err, stdout, stderr) => {
Expand Down Expand Up @@ -208,13 +212,7 @@ async function createTag(pr: WebhookPayloadPullRequestPullRequest) {
core.setOutput("pre_release", preRelease);

// Create comment
const params = {
repo,
issue_number: prNumber,
owner,
body: `:label: ${preRelease ? 'Pre-release' : 'Release'} \`${newTag}\` created. [See build.](https://circleci.com/gh/mercadolibre/${repo})`
};
const new_comment = await octokit.issues.createComment(params);
await addComment(prNumber, `:label: ${preRelease ? 'Pre-release' : 'Release'} \`${newTag}\` created. [See build.](https://circleci.com/gh/mercadolibre/${repo})`)
}

run()
Expand Down

0 comments on commit 67a403b

Please sign in to comment.