Compare commits

..

7 Commits

Author SHA1 Message Date
GitHub Actions
00f9595fb4 chore: update claude-code-base-action to v0.0.29 2025-07-01 21:38:26 +00:00
Dmitriy Shekhovtsov
79f2086fce feat: add sticky_comment input to reduce GitHub comment spam (#211)
* feat: no claude spam

* feat: add silent property

* feat: add silent property

* feat: add silent property

* chore: call me a sticky comment

* chore: applying review comments

* chore: apply review comments

* format

* reword

---------

Co-authored-by: Ashwin Bhat <ashwin@anthropic.com>
2025-07-01 10:37:39 -07:00
Julien Tanay
bcb072b63f docs: add FAQ entry about assigning in a private repo (#218) 2025-07-01 07:17:03 -07:00
GitHub Actions
e3b3e531a7 chore: update claude-code-base-action to v0.0.28 2025-07-01 02:57:05 +00:00
Derek Bredensteiner
a7665d3698 fix: resolve CI issues - formatting and TypeScript errors (#217)
* fixed file ingestion

* working binary files

* added replaced baseUrl

* fix: add type assertion for GitHub blob API response

Fixes TypeScript error where blobData was of type 'unknown' by adding
proper type assertion for the blob creation response.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Andrew Grosser <dioptre@gmail.com>
Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Andrew Grosser <dioptre@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-06-30 19:56:37 -07:00
taku.tsunose
91c510a769 fix: add missing LABEL_TRIGGER environment variable to prepare step (#209)
The label_trigger input was defined but not passed as an environment variable
to the prepare step, causing it to be undefined in the prepare script.
This adds the missing LABEL_TRIGGER environment variable mapping.

Co-authored-by: taku.tsunose <taku.tsunose@takutsunosenoMacBook-Pro.local>
2025-06-27 09:25:00 -07:00
GitHub Actions
1e006bf2d0 chore: update claude-code-base-action to v0.0.27 2025-06-26 01:00:41 +00:00
9 changed files with 108 additions and 10 deletions

4
FAQ.md
View File

@@ -12,6 +12,10 @@ The `github-actions` user cannot trigger subsequent GitHub Actions workflows. Th
Only users with **write permissions** to the repository can trigger Claude. This is a security feature to prevent unauthorized use. Make sure the user commenting has at least write access to the repository.
### Why can't I assign @claude to an issue on my repository?
If you're in a public repository, you should be able to assign to Claude without issue. If it's a private organization repository, you can only assign to users in your own organization, which Claude isn't. In this case, you'll need to make a custom user in that case.
### Why am I getting OIDC authentication errors?
If you're using the default GitHub App authentication, you must add the `id-token: write` permission to your workflow:

View File

@@ -85,6 +85,7 @@ jobs:
| `base_branch` | The base branch to use for creating new branches (e.g., 'main', 'develop') | No | - |
| `max_turns` | Maximum number of conversation turns Claude can take (limits back-and-forth exchanges) | No | - |
| `timeout_minutes` | Timeout in minutes for execution | No | `30` |
| `use_sticky_comment` | Use just one comment to deliver PR comments (only applies for pull_request event workflows) | No | `false` |
| `github_token` | GitHub token for Claude to operate with. **Only include this if you're connecting a custom GitHub app of your own!** | No | - |
| `model` | Model to use (provider-specific format required for Bedrock/Vertex) | No | - |
| `anthropic_model` | **DEPRECATED**: Use `model` instead. Kept for backward compatibility. | No | - |

View File

@@ -78,6 +78,10 @@ inputs:
description: "Timeout in minutes for execution"
required: false
default: "30"
use_sticky_comment:
description: "Use just one comment to deliver issue/PR comments"
required: false
default: "false"
outputs:
execution_file:
@@ -106,6 +110,7 @@ runs:
env:
TRIGGER_PHRASE: ${{ inputs.trigger_phrase }}
ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }}
LABEL_TRIGGER: ${{ inputs.label_trigger }}
BASE_BRANCH: ${{ inputs.base_branch }}
BRANCH_PREFIX: ${{ inputs.branch_prefix }}
ALLOWED_TOOLS: ${{ inputs.allowed_tools }}
@@ -115,11 +120,12 @@ runs:
MCP_CONFIG: ${{ inputs.mcp_config }}
OVERRIDE_GITHUB_TOKEN: ${{ inputs.github_token }}
GITHUB_RUN_ID: ${{ github.run_id }}
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
- name: Run Claude Code
id: claude-code
if: steps.prepare.outputs.contains_trigger == 'true'
uses: anthropics/claude-code-base-action@ba0557c14198bf2fbafbfe80932dde39e574a14c # v0.0.26
uses: anthropics/claude-code-base-action@bdaad5f64e7ad7a8c0be290a3c49d0fa7e1bb442 # v0.0.29
with:
prompt_file: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
allowed_tools: ${{ env.ALLOWED_TOOLS }}
@@ -179,6 +185,7 @@ runs:
TRIGGER_USERNAME: ${{ github.event.comment.user.login || github.event.issue.user.login || github.event.pull_request.user.login || github.event.sender.login || github.triggering_actor || github.actor || '' }}
PREPARE_SUCCESS: ${{ steps.prepare.outcome == 'success' }}
PREPARE_ERROR: ${{ steps.prepare.outputs.prepare_error || '' }}
USE_STICKY_COMMENT: ${{ inputs.use_sticky_comment }}
- name: Display Claude Code Report
if: steps.prepare.outputs.contains_trigger == 'true' && steps.claude-code.outputs.execution_file != ''

View File

@@ -36,6 +36,7 @@ export type ParsedGitHubContext = {
directPrompt: string;
baseBranch?: string;
branchPrefix: string;
useStickyComment: boolean;
};
};
@@ -62,6 +63,7 @@ export function parseGitHubContext(): ParsedGitHubContext {
directPrompt: process.env.DIRECT_PROMPT ?? "",
baseBranch: process.env.BASE_BRANCH,
branchPrefix: process.env.BRANCH_PREFIX ?? "claude/",
useStickyComment: process.env.STICKY_COMMENT === "true",
},
};

View File

@@ -9,6 +9,7 @@ import { appendFileSync } from "fs";
import { createJobRunLink, createCommentBody } from "./common";
import {
isPullRequestReviewCommentEvent,
isPullRequestEvent,
type ParsedGitHubContext,
} from "../../context";
import type { Octokit } from "@octokit/rest";
@@ -25,8 +26,39 @@ export async function createInitialComment(
try {
let response;
// Only use createReplyForReviewComment if it's a PR review comment AND we have a comment_id
if (isPullRequestReviewCommentEvent(context)) {
if (
context.inputs.useStickyComment &&
context.isPR &&
!isPullRequestEvent(context)
) {
const comments = await octokit.rest.issues.listComments({
owner,
repo,
issue_number: context.entityNumber,
});
const existingComment = comments.data.find(
(comment) =>
comment.user?.login.indexOf("claude[bot]") !== -1 ||
comment.body === initialBody,
);
if (existingComment) {
response = await octokit.rest.issues.updateComment({
owner,
repo,
comment_id: existingComment.id,
body: initialBody,
});
} else {
// Create new comment if no existing one found
response = await octokit.rest.issues.createComment({
owner,
repo,
issue_number: context.entityNumber,
body: initialBody,
});
}
} else if (isPullRequestReviewCommentEvent(context)) {
// Only use createReplyForReviewComment if it's a PR review comment AND we have a comment_id
response = await octokit.rest.pulls.createReplyForReviewComment({
owner,
repo,

View File

@@ -125,13 +125,58 @@ server.tool(
? filePath
: join(REPO_DIR, filePath);
const content = await readFile(fullPath, "utf-8");
return {
path: filePath,
mode: "100644",
type: "blob",
content: content,
};
// Check if file is binary (images, etc.)
const isBinaryFile =
/\.(png|jpg|jpeg|gif|webp|ico|pdf|zip|tar|gz|exe|bin|woff|woff2|ttf|eot)$/i.test(
filePath,
);
if (isBinaryFile) {
// For binary files, create a blob first using the Blobs API
const binaryContent = await readFile(fullPath);
// Create blob using Blobs API (supports encoding parameter)
const blobUrl = `${GITHUB_API_URL}/repos/${owner}/${repo}/git/blobs`;
const blobResponse = await fetch(blobUrl, {
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${githubToken}`,
"X-GitHub-Api-Version": "2022-11-28",
"Content-Type": "application/json",
},
body: JSON.stringify({
content: binaryContent.toString("base64"),
encoding: "base64",
}),
});
if (!blobResponse.ok) {
const errorText = await blobResponse.text();
throw new Error(
`Failed to create blob for ${filePath}: ${blobResponse.status} - ${errorText}`,
);
}
const blobData = (await blobResponse.json()) as { sha: string };
// Return tree entry with blob SHA
return {
path: filePath,
mode: "100644",
type: "blob",
sha: blobData.sha,
};
} else {
// For text files, include content directly in tree
const content = await readFile(fullPath, "utf-8");
return {
path: filePath,
mode: "100644",
type: "blob",
content: content,
};
}
}),
);

View File

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

View File

@@ -68,6 +68,7 @@ describe("checkWritePermissions", () => {
customInstructions: "",
directPrompt: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});

View File

@@ -36,6 +36,7 @@ describe("checkContainsTrigger", () => {
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -64,6 +65,7 @@ describe("checkContainsTrigger", () => {
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});
expect(checkContainsTrigger(context)).toBe(false);
@@ -276,6 +278,7 @@ describe("checkContainsTrigger", () => {
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -305,6 +308,7 @@ describe("checkContainsTrigger", () => {
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});
expect(checkContainsTrigger(context)).toBe(true);
@@ -334,6 +338,7 @@ describe("checkContainsTrigger", () => {
disallowedTools: [],
customInstructions: "",
branchPrefix: "claude/",
useStickyComment: false,
},
});
expect(checkContainsTrigger(context)).toBe(false);