Skip to content

Commit 657519b

Browse files
committed
Adding optional sticky_comment_app_bot_id and sticky_comment_app_bot_name options
1 parent c6a0789 commit 657519b

File tree

9 files changed

+73
-35
lines changed

9 files changed

+73
-35
lines changed

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ inputs:
106106
description: "Use just one comment to deliver issue/PR comments"
107107
required: false
108108
default: "false"
109+
sticky_comment_app_bot_id:
110+
description: "The ID of the app bot that will be used to create the sticky comment. Defaults to the Claude app bot ID."
111+
required: false
112+
default: "209825114"
113+
sticky_comment_app_bot_name:
114+
description: "The name of the app bot that will be used to create the sticky comment. Defaults to 'claude'."
115+
required: false
116+
default: "claude"
109117
use_commit_signing:
110118
description: "Enable commit signing using GitHub's commit signature verification. When false, Claude uses standard git commands"
111119
required: false
@@ -158,6 +166,8 @@ runs:
158166
OVERRIDE_GITHUB_TOKEN: ${{ inputs.github_token }}
159167
GITHUB_RUN_ID: ${{ github.run_id }}
160168
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
169+
STICKY_COMMENT_APP_BOT_ID: ${{ inputs.sticky_comment_app_bot_id }}
170+
STICKY_COMMENT_APP_BOT_NAME: ${{ inputs.sticky_comment_app_bot_name }}
161171
DEFAULT_WORKFLOW_TOKEN: ${{ github.token }}
162172
ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }}
163173
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
@@ -260,6 +270,8 @@ runs:
260270
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
261271
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
262272
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
273+
STICKY_COMMENT_APP_BOT_ID: ${{ inputs.sticky_comment_app_bot_id }}
274+
STICKY_COMMENT_APP_BOT_NAME: ${{ inputs.sticky_comment_app_bot_name }}
263275
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
264276

265277
- name: Display Claude Code Report

docs/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Comments appear as claude[bot] when the action uses its built-in authentication.
141141

142142
**Solution**: Remove `github_token` from your workflow file unless you're using a custom GitHub App.
143143

144-
**Note**: The `use_sticky_comment` feature only works with claude[bot] authentication. If you're using a custom `github_token`, sticky comments won't update properly since they expect the claude[bot] username.
144+
**Note**: The `use_sticky_comment` feature by default only works with claude[bot] authentication. If you're using a custom `github_token`, sticky comments won't update properly unless you also pass `sticky_comment_app_bot_id` or `sticky_comment_app_bot_name`.
145145

146146
## MCP Servers and Extended Functionality
147147

docs/usage.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,38 @@ jobs:
4646

4747
## Inputs
4848

49-
| Input | Description | Required | Default |
50-
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
51-
| `mode` | Execution mode: 'tag' (default - triggered by mentions/assignments), 'agent' (for automation), 'experimental-review' (for PR reviews) | No | `tag` |
52-
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
53-
| `claude_code_oauth_token` | Claude Code OAuth token (alternative to anthropic_api_key) | No\* | - |
54-
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
55-
| `override_prompt` | Complete replacement of Claude's prompt with custom template (supports variable substitution) | No | - |
56-
| `base_branch` | The base branch to use for creating new branches (e.g., 'main', 'develop') | No | - |
57-
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
58-
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
59-
| `use_sticky_comment` | Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | `false` |
60-
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
61-
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
62-
| `fallback_model` | Enable automatic fallback to specified model when primary model is unavailable | No | - |
63-
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |
64-
| `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` |
65-
| `use_vertex` | Use Google Vertex AI with OIDC authentication instead of direct Anthropic API | No | `false` |
66-
| `allowed_tools` | Additional tools for Claude to use (the base GitHub tools will always be included) | No | "" |
67-
| `disallowed_tools` | Tools that Claude should never use | No | "" |
68-
| `custom_instructions` | Additional custom instructions to include in the prompt for Claude | No | "" |
69-
| `mcp_config` | Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers | No | "" |
70-
| `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
71-
| `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - |
72-
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
73-
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
74-
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
75-
| `settings` | Claude Code settings as JSON string or path to settings JSON file | No | "" |
76-
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
77-
| `experimental_allowed_domains` | Restrict network access to these domains only (newline-separated). | No | "" |
78-
| `use_commit_signing` | Enable commit signing using GitHub's commit signature verification. When false, Claude uses standard git commands | No | `false` |
49+
| Input | Description | Required | Default |
50+
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------- | ----------- |
51+
| `mode` | Execution mode: 'tag' (default - triggered by mentions/assignments), 'agent' (for automation), 'experimental-review' (for PR reviews) | No | `tag` |
52+
| `anthropic_api_key` | Anthropic API key (required for direct API, not needed for Bedrock/Vertex) | No\* | - |
53+
| `claude_code_oauth_token` | Claude Code OAuth token (alternative to anthropic_api_key) | No\* | - |
54+
| `direct_prompt` | Direct prompt for Claude to execute automatically without needing a trigger (for automated workflows) | No | - |
55+
| `override_prompt` | Complete replacement of Claude's prompt with custom template (supports variable substitution) | No | - |
56+
| `base_branch` | The base branch to use for creating new branches (e.g., 'main', 'develop') | No | - |
57+
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
58+
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
59+
| `use_sticky_comment` | Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | `false` |
60+
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
61+
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
62+
| `fallback_model` | Enable automatic fallback to specified model when primary model is unavailable | No | - |
63+
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |
64+
| `use_bedrock` | Use Amazon Bedrock with OIDC authentication instead of direct Anthropic API | No | `false` |
65+
| `use_vertex` | Use Google Vertex AI with OIDC authentication instead of direct Anthropic API | No | `false` |
66+
| `allowed_tools` | Additional tools for Claude to use (the base GitHub tools will always be included) | No | "" |
67+
| `disallowed_tools` | Tools that Claude should never use | No | "" |
68+
| `custom_instructions` | Additional custom instructions to include in the prompt for Claude | No | "" |
69+
| `mcp_config` | Additional MCP configuration (JSON string) that merges with the built-in GitHub MCP servers | No | "" |
70+
| `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - |
71+
| `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - |
72+
| `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` |
73+
| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` |
74+
| `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" |
75+
| `settings` | Claude Code settings as JSON string or path to settings JSON file | No | "" |
76+
| `additional_permissions` | Additional permissions to enable. Currently supports 'actions: read' for viewing workflow results | No | "" |
77+
| `experimental_allowed_domains` | Restrict network access to these domains only (newline-separated). | No | "" |
78+
| `use_commit_signing` | Enable commit signing using GitHub's commit signature verification. When false, Claude uses standard git commands | No | `false` |
79+
| `sticky_comment_app_bot_id` | The ID of the app bot that will be used to create the sticky comment. Defaults to the Claude app bot ID. | No | `209825114` |
80+
| `sticky_comment_app_bot_name` | The name of the app bot that will be used to create the sticky comment. Defaults to 'claude'. | No | `claude` |
7981

8082
\*Required when using direct Anthropic API (default and when not using Bedrock or Vertex)
8183

src/github/context.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ type BaseContext = {
7777
useStickyComment: boolean;
7878
additionalPermissions: Map<string, string>;
7979
useCommitSigning: boolean;
80+
stickyCommentAppBotId: number;
81+
stickyCommentAppBotName: string;
8082
};
8183
};
8284

@@ -136,6 +138,11 @@ export function parseGitHubContext(): GitHubContext {
136138
process.env.ADDITIONAL_PERMISSIONS ?? "",
137139
),
138140
useCommitSigning: process.env.USE_COMMIT_SIGNING === "true",
141+
stickyCommentAppBotId: parseInt(
142+
process.env.STICKY_COMMENT_APP_BOT_ID ?? "209825114",
143+
),
144+
stickyCommentAppBotName:
145+
process.env.STICKY_COMMENT_APP_BOT_NAME ?? "claude",
139146
},
140147
};
141148

src/github/operations/comments/create-initial.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
} from "../../context";
1515
import type { Octokit } from "@octokit/rest";
1616

17-
const CLAUDE_APP_BOT_ID = 209825114;
18-
1917
export async function createInitialComment(
2018
octokit: Octokit,
2119
context: ParsedGitHubContext,
@@ -39,10 +37,13 @@ export async function createInitialComment(
3937
issue_number: context.entityNumber,
4038
});
4139
const existingComment = comments.data.find((comment) => {
42-
const idMatch = comment.user?.id === CLAUDE_APP_BOT_ID;
40+
const idMatch =
41+
comment.user?.id === context.inputs.stickyCommentAppBotId;
4342
const botNameMatch =
4443
comment.user?.type === "Bot" &&
45-
comment.user?.login.toLowerCase().includes("claude");
44+
comment.user?.login
45+
.toLowerCase()
46+
.includes(context.inputs.stickyCommentAppBotName);
4647
const bodyMatch = comment.body === initialBody;
4748

4849
return idMatch || botNameMatch || bodyMatch;

test/install-mcp-server.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, test, expect, beforeEach, afterEach, spyOn } from "bun:test";
22
import { prepareMcpConfig } from "../src/mcp/install-mcp-server";
33
import * as core from "@actions/core";
44
import type { ParsedGitHubContext } from "../src/github/context";
5+
import { defaultStickyCommentInputs } from "./mockContext";
56

67
describe("prepareMcpConfig", () => {
78
let consoleInfoSpy: any;
@@ -35,6 +36,7 @@ describe("prepareMcpConfig", () => {
3536
overridePrompt: "",
3637
branchPrefix: "",
3738
useStickyComment: false,
39+
...defaultStickyCommentInputs,
3840
additionalPermissions: new Map(),
3941
useCommitSigning: false,
4042
},

test/mockContext.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import type {
1010
PullRequestReviewCommentEvent,
1111
} from "@octokit/webhooks-types";
1212

13+
export const defaultStickyCommentInputs = {
14+
stickyCommentAppBotId: 209825114,
15+
stickyCommentAppBotName: "claude",
16+
};
17+
1318
const defaultInputs = {
1419
mode: "tag" as const,
1520
triggerPhrase: "/claude",
@@ -26,6 +31,7 @@ const defaultInputs = {
2631
timeoutMinutes: 30,
2732
branchPrefix: "claude/",
2833
useStickyComment: false,
34+
...defaultStickyCommentInputs,
2935
additionalPermissions: new Map<string, string>(),
3036
useCommitSigning: false,
3137
};

test/permissions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { describe, expect, test, spyOn, beforeEach, afterEach } from "bun:test";
22
import * as core from "@actions/core";
33
import { checkWritePermissions } from "../src/github/validation/permissions";
44
import type { ParsedGitHubContext } from "../src/github/context";
5+
import { defaultStickyCommentInputs } from "./mockContext";
56

67
describe("checkWritePermissions", () => {
78
let coreInfoSpy: any;
@@ -71,6 +72,7 @@ describe("checkWritePermissions", () => {
7172
overridePrompt: "",
7273
branchPrefix: "claude/",
7374
useStickyComment: false,
75+
...defaultStickyCommentInputs,
7476
additionalPermissions: new Map(),
7577
useCommitSigning: false,
7678
},

test/trigger-validation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type {
2020
PullRequestReviewEvent,
2121
} from "@octokit/webhooks-types";
2222
import type { ParsedGitHubContext } from "../src/github/context";
23+
import { defaultStickyCommentInputs } from "./mockContext";
2324

2425
describe("checkContainsTrigger", () => {
2526
describe("direct prompt trigger", () => {
@@ -39,6 +40,7 @@ describe("checkContainsTrigger", () => {
3940
customInstructions: "",
4041
branchPrefix: "claude/",
4142
useStickyComment: false,
43+
...defaultStickyCommentInputs,
4244
additionalPermissions: new Map(),
4345
useCommitSigning: false,
4446
},
@@ -72,6 +74,7 @@ describe("checkContainsTrigger", () => {
7274
customInstructions: "",
7375
branchPrefix: "claude/",
7476
useStickyComment: false,
77+
...defaultStickyCommentInputs,
7578
additionalPermissions: new Map(),
7679
useCommitSigning: false,
7780
},
@@ -289,6 +292,7 @@ describe("checkContainsTrigger", () => {
289292
customInstructions: "",
290293
branchPrefix: "claude/",
291294
useStickyComment: false,
295+
...defaultStickyCommentInputs,
292296
additionalPermissions: new Map(),
293297
useCommitSigning: false,
294298
},
@@ -323,6 +327,7 @@ describe("checkContainsTrigger", () => {
323327
customInstructions: "",
324328
branchPrefix: "claude/",
325329
useStickyComment: false,
330+
...defaultStickyCommentInputs,
326331
additionalPermissions: new Map(),
327332
useCommitSigning: false,
328333
},
@@ -357,6 +362,7 @@ describe("checkContainsTrigger", () => {
357362
customInstructions: "",
358363
branchPrefix: "claude/",
359364
useStickyComment: false,
365+
...defaultStickyCommentInputs,
360366
additionalPermissions: new Map(),
361367
useCommitSigning: false,
362368
},

0 commit comments

Comments
 (0)