diff --git a/action.js b/action.js index c79dddf..bdcfe36 100644 --- a/action.js +++ b/action.js @@ -163,24 +163,29 @@ async function run(octokit, context) { // no previous or edit failed if (!commentId) { - console.log('Creating new comment'); - try { - await octokit.issues.createComment(comment); - } catch (e) { - console.log(`Error creating comment: ${e.message}`); - console.log(`Submitting a PR review comment instead...`); + const threshold = Number(getInput('delta-threshold')); + if (!isNaN(threshold) && Math.abs(diff.delta) < threshold) { + console.log(`Skipping comment creation because size delta ${Math.abs(diff.delta)} is less than configured threshold ${threshold}`); + } else { + console.log('Creating new comment'); try { - const issue = context.issue || pr; - await octokit.pulls.createReview({ - owner: issue.owner, - repo: issue.repo, - pull_number: issue.number, - event: 'COMMENT', - body: comment.body - }); + await octokit.issues.createComment(comment); } catch (e) { - console.log('Error creating PR review.'); - outputRawMarkdown = true; + console.log(`Error creating comment: ${e.message}`); + console.log(`Submitting a PR review comment instead...`); + try { + const issue = context.issue || pr; + await octokit.pulls.createReview({ + owner: issue.owner, + repo: issue.repo, + pull_number: issue.number, + event: 'COMMENT', + body: comment.body + }); + } catch (e) { + console.log('Error creating PR review.'); + outputRawMarkdown = true; + } } } } diff --git a/action.yml b/action.yml index 6086159..ebfee36 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,8 @@ inputs: default: 'true' omit-unchanged: description: 'Exclude unchanged files from the sizes table entirely' + delta-threshold: + description: 'Minimum absolute size change required as condition to report' runs: using: 'node12' main: 'index.js' \ No newline at end of file