From 5ba1f05111e2942682b49db6a32fcd80545fdfaa Mon Sep 17 00:00:00 2001 From: Rob van der Leek <5324924+robvanderleek@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:50:59 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20badge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- src/action.ts | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3d69c36..5b6c197 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # codelimit-action +[![Checked with Code Limit](https://github.com/getcodelimit/codelimit-action/blob/_codelimit_reports/main/badge.svg)](https://github.com/getcodelimit/codelimit) + To run Code Limit on every push and before every merge to main, append it to your GH Action workflow: ```yaml @@ -31,4 +33,4 @@ To upload the report to Code Limit, add the following step to your workflow: with: upload: true token: ${{ secrets.GITHUB_TOKEN }} -``` \ No newline at end of file +``` diff --git a/src/action.ts b/src/action.ts index 14c7570..478bc9b 100644 --- a/src/action.ts +++ b/src/action.ts @@ -162,18 +162,18 @@ async function main() { exitCode = await exec(filename, ['app', 'upload', '--token', token, slug, branch]); } } - // const doCheck = getInput('check') || true; - // if (doCheck && exitCode === 0) { - // const changedFiles = await getChangedFiles(token); - // console.log(`Number of files changed: ${changedFiles.length}`); - // if (changedFiles.length === 0) { - // console.log('No files changed, skipping Code Limit'); - // } else { - // console.log('Running Code Limit...'); - // exitCode = await exec(filename, ['check'].concat(changedFiles), {ignoreReturnCode: true}); - // } - // } - // fs.unlinkSync(filename); + const doCheck = getInput('check') || true; + if (doCheck && exitCode === 0) { + const changedFiles = await getChangedFiles(token); + console.log(`Number of files changed: ${changedFiles.length}`); + if (changedFiles.length === 0) { + console.log('No files changed, skipping Code Limit'); + } else { + console.log('Running Code Limit...'); + exitCode = await exec(filename, ['check'].concat(changedFiles), {ignoreReturnCode: true}); + } + } + fs.unlinkSync(filename); console.log('Done!'); process.exit(exitCode); }