diff --git a/README.md b/README.md index b1a7f35..b3765bf 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ Optional. The name of the label, defaults to lfs-detected! Optional. The color of the label, defaults to ff1493. +### `sendComment` + +Optional. If set to false, disables sending comments. + +Default `true`. + ## Outputs ### `lfsFiles` diff --git a/action.yml b/action.yml index 9a45dcb..7ed8a64 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: required: false default: ff1493 description: The color of the label, defaults to ff1493 + sendComment: + required: false + default: true + description: Disable sending comments outputs: lfsFiles: # output will be available to future steps description: "Array of possible detected large file(s)" diff --git a/src/index.ts b/src/index.ts index a3f7935..8b679fe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -88,10 +88,9 @@ async function run() { core.info('Detected file(s) that should be in LFS: '); core.info(lsfFiles.join('\n')); - const body = getCommentBody( - largeFiles, - accidentallyCheckedInLsfFiles, - fsl + core.setOutput('lfsFiles', lsfFiles); + core.setFailed( + 'Large file(s) detected! Setting PR status to failed. Consider using git-lfs to track the LFS file(s)' ); await Promise.all([ @@ -99,16 +98,25 @@ async function run() { ...issueBaseProps, labels: [labelName], }), - octokit.rest.issues.createComment({ - ...issueBaseProps, - body, - }), ]); - - core.setOutput('lfsFiles', lsfFiles); - core.setFailed( - 'Large file(s) detected! Setting PR status to failed. Consider using git-lfs to track the LFS file(s)' - ); + + const send_comment = core.getInput('sendComment'); + if (send_comment === "" || send_comment === "true") { + const body = getCommentBody( + largeFiles, + accidentallyCheckedInLsfFiles, + fsl + ); + + await Promise.all([ + octokit.rest.issues.createComment({ + ...issueBaseProps, + body, + }), + ]); + } else if (send_comment !== "false") { + throw new Error("sendComment must be either true or false"); + } } else { core.info('No large file(s) detected...');