feat(config): add branch prefix configuration (#197)

This commit is contained in:
Stefano Amorelli
2025-06-26 00:01:25 +03:00
committed by GitHub
parent b0d9b8c4cd
commit 032008d3b6
7 changed files with 17 additions and 2 deletions

View File

@@ -96,6 +96,7 @@ jobs:
| `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
| `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - |
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)

View File

@@ -19,6 +19,10 @@ inputs:
base_branch:
description: "The branch to use as the base/source when creating new branches (defaults to repository default branch)"
required: false
branch_prefix:
description: "The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format)"
required: false
default: "claude/"
# Claude Code configuration
model:
@@ -103,6 +107,7 @@ runs:
TRIGGER_PHRASE: ${{ inputs.trigger_phrase }}
ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }}
BASE_BRANCH: ${{ inputs.base_branch }}
BRANCH_PREFIX: ${{ inputs.branch_prefix }}
ALLOWED_TOOLS: ${{ inputs.allowed_tools }}
DISALLOWED_TOOLS: ${{ inputs.disallowed_tools }}
CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }}

View File

@@ -35,6 +35,7 @@ export type ParsedGitHubContext = {
customInstructions: string;
directPrompt: string;
baseBranch?: string;
branchPrefix: string;
};
};
@@ -60,6 +61,7 @@ export function parseGitHubContext(): ParsedGitHubContext {
customInstructions: process.env.CUSTOM_INSTRUCTIONS ?? "",
directPrompt: process.env.DIRECT_PROMPT ?? "",
baseBranch: process.env.BASE_BRANCH,
branchPrefix: process.env.BRANCH_PREFIX ?? "claude/",
},
};

View File

@@ -26,7 +26,7 @@ export async function setupBranch(
): Promise<BranchInfo> {
const { owner, repo } = context.repository;
const entityNumber = context.entityNumber;
const { baseBranch } = context.inputs;
const { baseBranch, branchPrefix } = context.inputs;
const isPR = context.isPR;
if (isPR) {
@@ -97,7 +97,7 @@ export async function setupBranch(
.split("T")
.join("_");
const newBranch = `claude/${entityType}-${entityNumber}-${timestamp}`;
const newBranch = `${branchPrefix}${entityType}-${entityNumber}-${timestamp}`;
try {
// Get the SHA of the source branch

View File

@@ -19,6 +19,7 @@ const defaultInputs = {
useBedrock: false,
useVertex: false,
timeoutMinutes: 30,
branchPrefix: "claude/",
};
const defaultRepository = {

View File

@@ -67,6 +67,7 @@ describe("checkWritePermissions", () => {
disallowedTools: [],
customInstructions: "",
directPrompt: "",
branchPrefix: "claude/",
},
});

View File

@@ -35,6 +35,7 @@ describe("checkContainsTrigger", () => {
allowedTools: [],
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -62,6 +63,7 @@ describe("checkContainsTrigger", () => {
allowedTools: [],
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
},
});
expect(checkContainsTrigger(context)).toBe(false);
@@ -273,6 +275,7 @@ describe("checkContainsTrigger", () => {
allowedTools: [],
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -301,6 +304,7 @@ describe("checkContainsTrigger", () => {
allowedTools: [],
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -329,6 +333,7 @@ describe("checkContainsTrigger", () => {
allowedTools: [],
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
},
});
expect(checkContainsTrigger(context)).toBe(false);