diff --git a/dist/index.js b/dist/index.js index ce67462..b132ea9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -46753,6 +46753,7 @@ var require_github2 = __commonJS({ exports2.createPRComment = createPRComment; exports2.updateComment = updateComment; exports2.isPullRequest = isPullRequest; + exports2.isPullRequestFromFork = isPullRequestFromFork; exports2.getSourceBranch = getSourceBranch; exports2.createBranchIfNotExists = createBranchIfNotExists; var github_12 = require_github(); @@ -46887,6 +46888,10 @@ var require_github2 = __commonJS({ function isPullRequest() { return github_12.context.eventName === "pull_request"; } + function isPullRequestFromFork() { + var _a, _b; + return isPullRequest() && ((_b = (_a = github_12.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.repo) === null || _b === void 0 ? void 0 : _b.fork) === true; + } function getSourceBranch() { if (isPullRequest()) { return process.env.GITHUB_HEAD_REF; @@ -49110,18 +49115,19 @@ function checkChangedFiles(octokit, clBinary) { function main() { return __awaiter(this, void 0, void 0, function* () { console.log(`Code Limit action, version: ${version_1.version.revision}`); - console.log(JSON.stringify(github_1.context)); let exitCode = 0; const clBinary = yield (0, codelimit_1.downloadCodeLimitBinary)(); console.log("Scanning codebase..."); yield (0, exec_1.exec)(clBinary, ["scan", "."]); const markdownReport = yield generateMarkdownReport(clBinary); const octokit = new action_1.Octokit({ auth: (0, core_1.getInput)("token") }); - yield updateReportsBranch(octokit, markdownReport); const doCheck = (0, core_1.getInput)("check") || true; if (doCheck) { exitCode = yield checkChangedFiles(octokit, clBinary); } + if (!(0, github_2.isPullRequestFromFork)()) { + yield updateReportsBranch(octokit, markdownReport); + } fs_1.default.unlinkSync(clBinary); console.log("Done!"); process.exit(exitCode); diff --git a/src/action.ts b/src/action.ts index c85dac3..a1b1cb5 100644 --- a/src/action.ts +++ b/src/action.ts @@ -9,7 +9,7 @@ import { getRepoName, getRepoOwner, getSourceBranch, - isPullRequest, updateComment + isPullRequest, isPullRequestFromFork, updateComment } from "./github"; import {exec, getExecOutput} from "@actions/exec"; import {downloadCodeLimitBinary, getBadgeContent, getReportContent} from "./codelimit"; @@ -82,18 +82,19 @@ async function checkChangedFiles(octokit: Octokit, clBinary: string): Promise