mirror of
https://github.com/mshick/add-pr-comment.git
synced 2025-12-31 14:20:32 +11:00
Add update-only configuration option (#92)
This commit is contained in:
parent
387ece43e3
commit
1dff58b1a3
11 changed files with 3311 additions and 10787 deletions
|
|
@ -44,6 +44,7 @@ async function getInputs() {
|
|||
const proxyUrl = core.getInput('proxy-url', { required: false }).replace(/\/$/, '');
|
||||
const allowRepeats = core.getInput('allow-repeats', { required: true }) === 'true';
|
||||
const refreshMessagePosition = core.getInput('refresh-message-position', { required: false }) === 'true';
|
||||
const updateOnly = core.getInput('update-only', { required: false }) === 'true';
|
||||
if (messageInput && messagePath) {
|
||||
throw new Error('must specify only one, message or message-path');
|
||||
}
|
||||
|
|
@ -87,6 +88,7 @@ async function getInputs() {
|
|||
commitSha: github.context.sha,
|
||||
owner: repoOwner || payload.repo.owner,
|
||||
repo: repoName || payload.repo.repo,
|
||||
updateOnly: updateOnly,
|
||||
};
|
||||
}
|
||||
exports.getInputs = getInputs;
|
||||
|
|
|
|||
12
lib/main.js
12
lib/main.js
|
|
@ -31,7 +31,7 @@ const issues_1 = require("./issues");
|
|||
const proxy_1 = require("./proxy");
|
||||
const run = async () => {
|
||||
try {
|
||||
const { allowRepeats, message, messageId, refreshMessagePosition, repoToken, proxyUrl, issue, pullRequestNumber, commitSha, repo, owner, } = await (0, config_1.getInputs)();
|
||||
const { allowRepeats, message, messageId, refreshMessagePosition, repoToken, proxyUrl, issue, pullRequestNumber, commitSha, repo, owner, updateOnly, } = await (0, config_1.getInputs)();
|
||||
const octokit = github.getOctokit(repoToken);
|
||||
let issueNumber;
|
||||
if (issue) {
|
||||
|
|
@ -57,6 +57,12 @@ const run = async () => {
|
|||
core.debug(`existing comment found with id: ${existingCommentId}`);
|
||||
}
|
||||
}
|
||||
// if no existing comment and updateOnly is true, exit
|
||||
if (!existingCommentId && updateOnly) {
|
||||
core.info('no existing comment found and update-only is true, exiting');
|
||||
core.setOutput('comment-created', 'false');
|
||||
return;
|
||||
}
|
||||
let comment;
|
||||
const body = `${messageId}\n\n${message}`;
|
||||
if (proxyUrl) {
|
||||
|
|
@ -94,6 +100,10 @@ const run = async () => {
|
|||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err);
|
||||
}
|
||||
if (err instanceof Error) {
|
||||
core.setFailed(err.message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue