Check if on default branch before uploading database

This commit is contained in:
Robert 2021-06-16 14:17:50 +01:00
parent 429471162a
commit d693b3cb0d
6 changed files with 49 additions and 5 deletions

13
lib/actions-util.js generated
View file

@ -540,4 +540,17 @@ function getRelativeScriptPath() {
return path.relative(actionsDirectory, __filename);
}
exports.getRelativeScriptPath = getRelativeScriptPath;
// Is the version of the repository we are currently analyzing from the default branch,
// or alternatively from another branch or a pull request.
async function isAnalyzingDefaultBranch() {
var _a, _b;
// Get the current ref and trim and refs/heads/ prefix
let currentRef = await getRef();
currentRef = currentRef.startsWith("refs/heads/")
? currentRef.substr("refs/heads/".length)
: currentRef;
const eventJson = JSON.parse(fs.readFileSync(util_1.getRequiredEnvParam("GITHUB_EVENT_PATH"), "utf-8"));
return currentRef === ((_b = (_a = eventJson) === null || _a === void 0 ? void 0 : _a.repository) === null || _b === void 0 ? void 0 : _b.default_branch);
}
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
//# sourceMappingURL=actions-util.js.map