From a852836a30836b471ee05f2349d75f0df59bd164 Mon Sep 17 00:00:00 2001 From: shiftinv Date: Fri, 30 Sep 2022 14:59:30 +0200 Subject: [PATCH] feat: handle branch/tag creation --- lib/filter.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; }