feat: handle branch/tag creation

This commit is contained in:
shiftinv 2022-09-30 14:59:30 +02:00
parent e73128ddf3
commit a852836a30
1 changed files with 17 additions and 1 deletions

View File

@ -69,7 +69,7 @@ export default async function filter(
return "bot";
}
// ignore branch/tag if configured
// ignore branch/tag push
const refMatch = /^refs\/([^\/]+)\/(.+)$/.exec(json.ref);
if (event === "push" && refMatch) {
// check if branch is allowed
@ -86,5 +86,21 @@ export default async function filter(
}
}
// ignore creation of branch/tag
if (event === "create") {
// check if branch is allowed
if (
json.ref_type === "branch" && config.allowBranches !== undefined &&
!config.allowBranches.includes(json.ref)
) {
return `branch '${json.ref}' not in ${JSON.stringify(config.allowBranches)}`;
}
// check if it's a tag
if (json.ref_type == "tag" && config.hideTags === true) {
return `tag '${json.ref}'`;
}
}
return null;
}