diff --git a/lib/filter.ts b/lib/filter.ts index 9d3da99..b2c7332 100644 --- a/lib/filter.ts +++ b/lib/filter.ts @@ -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; }