From 726d5808b55a5d1d06b14a63a6016189fbe69c95 Mon Sep 17 00:00:00 2001 From: Cole Davis Date: Fri, 12 Sep 2025 14:51:33 -0400 Subject: [PATCH] Add branch-name-template config option --- action.yml | 5 +++++ src/github/context.ts | 2 ++ src/github/operations/branch.ts | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c36e8bb..b3d4bed 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,10 @@ inputs: description: "The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format)" required: false default: "claude/" + branch_name_template: + description: "Template for branch naming. Available variables: {{prefix}}, {{entityType}}, {{entityNumber}}, {{timestamp}}, {{year}}, {{month}}, {{day}}, {{hour}}, {{minute}}, {{sha}}. Default: '{{prefix}}{{entityType}}-{{entityNumber}}-{{timestamp}}'" + required: false + default: "" allowed_bots: description: "Comma-separated list of allowed bot usernames, or '*' to allow all bots. Empty string (default) allows no bots." required: false @@ -150,6 +154,7 @@ runs: LABEL_TRIGGER: ${{ inputs.label_trigger }} BASE_BRANCH: ${{ inputs.base_branch }} BRANCH_PREFIX: ${{ inputs.branch_prefix }} + BRANCH_NAME_TEMPLATE: ${{ inputs.branch_name_template }} OVERRIDE_GITHUB_TOKEN: ${{ inputs.github_token }} ALLOWED_BOTS: ${{ inputs.allowed_bots }} ALLOWED_NON_WRITE_USERS: ${{ inputs.allowed_non_write_users }} diff --git a/src/github/context.ts b/src/github/context.ts index 56a9233..7e1d3fd 100644 --- a/src/github/context.ts +++ b/src/github/context.ts @@ -88,6 +88,7 @@ type BaseContext = { labelTrigger: string; baseBranch?: string; branchPrefix: string; + branchNameTemplate?: string; useStickyComment: boolean; useCommitSigning: boolean; botId: string; @@ -143,6 +144,7 @@ export function parseGitHubContext(): GitHubContext { labelTrigger: process.env.LABEL_TRIGGER ?? "", baseBranch: process.env.BASE_BRANCH, branchPrefix: process.env.BRANCH_PREFIX ?? "claude/", + branchNameTemplate: process.env.BRANCH_NAME_TEMPLATE, useStickyComment: process.env.USE_STICKY_COMMENT === "true", useCommitSigning: process.env.USE_COMMIT_SIGNING === "true", botId: process.env.BOT_ID ?? String(CLAUDE_APP_BOT_ID), diff --git a/src/github/operations/branch.ts b/src/github/operations/branch.ts index 42e7829..994c695 100644 --- a/src/github/operations/branch.ts +++ b/src/github/operations/branch.ts @@ -26,7 +26,7 @@ export async function setupBranch( ): Promise { const { owner, repo } = context.repository; const entityNumber = context.entityNumber; - const { baseBranch, branchPrefix } = context.inputs; + const { baseBranch, branchPrefix, branchNameTemplate } = context.inputs; const isPR = context.isPR; if (isPR) {