Skip to content

Commit 1175872

Browse files
committed
Adding optional sticky_comment_app_bot_id and sticky_comment_app_bot_name options
1 parent bc423b4 commit 1175872

File tree

9 files changed

+74
-36
lines changed

9 files changed

+74
-36
lines changed

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ inputs:
110110
description: "Use just one comment to deliver issue/PR comments"
111111
required: false
112112
default: "false"
113+
sticky_comment_app_bot_id:
114+
description: "The ID of the app bot that will be used to create the sticky comment. Defaults to the Claude app bot ID."
115+
required: false
116+
default: "209825114"
117+
sticky_comment_app_bot_name:
118+
description: "The name of the app bot that will be used to create the sticky comment. Defaults to 'claude'."
119+
required: false
120+
default: "claude"
113121
use_commit_signing:
114122
description: "Enable commit signing using GitHub's commit signature verification. When false, Claude uses standard git commands"
115123
required: false
@@ -163,6 +171,8 @@ runs:
163171
ALLOWED_BOTS: ${{ inputs.allowed_bots }}
164172
GITHUB_RUN_ID: ${{ github.run_id }}
165173
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
174+
STICKY_COMMENT_APP_BOT_ID: ${{ inputs.sticky_comment_app_bot_id }}
175+
STICKY_COMMENT_APP_BOT_NAME: ${{ inputs.sticky_comment_app_bot_name }}
166176
DEFAULT_WORKFLOW_TOKEN: ${{ github.token }}
167177
ADDITIONAL_PERMISSIONS: ${{ inputs.additional_permissions }}
168178
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
@@ -265,6 +275,8 @@ runs:
265275
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
266276
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
267277
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
278+
STICKY_COMMENT_APP_BOT_ID: ${{ inputs.sticky_comment_app_bot_id }}
279+
STICKY_COMMENT_APP_BOT_NAME: ${{ inputs.sticky_comment_app_bot_name }}
268280
USE_COMMIT_SIGNING: ${{ inputs.use_commit_signing }}
269281

270282
- 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: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -48,37 +48,39 @@ jobs:
4848

4949
## Inputs
5050

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

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

src/github/context.ts

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

@@ -138,6 +140,11 @@ export function parseGitHubContext(): GitHubContext {
138140
),
139141
useCommitSigning: process.env.USE_COMMIT_SIGNING === "true",
140142
allowedBots: process.env.ALLOWED_BOTS ?? "",
143+
stickyCommentAppBotId: parseInt(
144+
process.env.STICKY_COMMENT_APP_BOT_ID ?? "209825114",
145+
),
146+
stickyCommentAppBotName:
147+
process.env.STICKY_COMMENT_APP_BOT_NAME ?? "claude",
141148
},
142149
};
143150

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
allowedBots: "",

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
allowedBots: "",

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
allowedBots: "",

0 commit comments

Comments
 (0)