mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 23:14:13 +08:00
Compare commits
1 Commits
v0.0.23
...
ashwin/tes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a39f0435dc |
2
.github/workflows/issue-triage.yml
vendored
2
.github/workflows/issue-triage.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
|||||||
"--rm",
|
"--rm",
|
||||||
"-e",
|
"-e",
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||||
"ghcr.io/github/github-mcp-server:sha-6d69797"
|
"ghcr.io/github/github-mcp-server:sha-7aced2b"
|
||||||
],
|
],
|
||||||
"env": {
|
"env": {
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
|
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|||||||
138
.github/workflows/release.yml
vendored
138
.github/workflows/release.yml
vendored
@@ -1,138 +0,0 @@
|
|||||||
name: Create Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
dry_run:
|
|
||||||
description: "Dry run (only show what would be created)"
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
create-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
outputs:
|
|
||||||
next_version: ${{ steps.next_version.outputs.next_version }}
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Get latest tag
|
|
||||||
id: get_latest_tag
|
|
||||||
run: |
|
|
||||||
# Get only version tags (v + number pattern)
|
|
||||||
latest_tag=$(git tag -l 'v[0-9]*' | sort -V | tail -1 || echo "v0.0.0")
|
|
||||||
if [ -z "$latest_tag" ]; then
|
|
||||||
latest_tag="v0.0.0"
|
|
||||||
fi
|
|
||||||
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
|
|
||||||
echo "Latest tag: $latest_tag"
|
|
||||||
|
|
||||||
- name: Calculate next version
|
|
||||||
id: next_version
|
|
||||||
run: |
|
|
||||||
latest_tag="${{ steps.get_latest_tag.outputs.latest_tag }}"
|
|
||||||
# Remove 'v' prefix and split by dots
|
|
||||||
version=${latest_tag#v}
|
|
||||||
IFS='.' read -ra VERSION_PARTS <<< "$version"
|
|
||||||
|
|
||||||
# Increment patch version
|
|
||||||
major=${VERSION_PARTS[0]:-0}
|
|
||||||
minor=${VERSION_PARTS[1]:-0}
|
|
||||||
patch=${VERSION_PARTS[2]:-0}
|
|
||||||
patch=$((patch + 1))
|
|
||||||
|
|
||||||
next_version="v${major}.${minor}.${patch}"
|
|
||||||
echo "next_version=$next_version" >> $GITHUB_OUTPUT
|
|
||||||
echo "Next version: $next_version"
|
|
||||||
|
|
||||||
- name: Display dry run info
|
|
||||||
if: ${{ inputs.dry_run }}
|
|
||||||
run: |
|
|
||||||
echo "🔍 DRY RUN MODE"
|
|
||||||
echo "Would create tag: ${{ steps.next_version.outputs.next_version }}"
|
|
||||||
echo "From commit: ${{ github.sha }}"
|
|
||||||
echo "Previous tag: ${{ steps.get_latest_tag.outputs.latest_tag }}"
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
if: ${{ !inputs.dry_run }}
|
|
||||||
run: |
|
|
||||||
next_version="${{ steps.next_version.outputs.next_version }}"
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
|
|
||||||
git tag -a "$next_version" -m "Release $next_version"
|
|
||||||
git push origin "$next_version"
|
|
||||||
|
|
||||||
- name: Create Release
|
|
||||||
if: ${{ !inputs.dry_run }}
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
run: |
|
|
||||||
next_version="${{ steps.next_version.outputs.next_version }}"
|
|
||||||
|
|
||||||
gh release create "$next_version" \
|
|
||||||
--title "$next_version" \
|
|
||||||
--generate-notes \
|
|
||||||
--latest=false # We want to keep beta as the latest
|
|
||||||
|
|
||||||
update-beta-tag:
|
|
||||||
needs: create-release
|
|
||||||
if: ${{ !inputs.dry_run }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Update beta tag
|
|
||||||
run: |
|
|
||||||
# Get the latest version tag
|
|
||||||
VERSION=$(git tag -l 'v[0-9]*' | sort -V | tail -1)
|
|
||||||
|
|
||||||
# Update the beta tag to point to this release
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git tag -fa beta -m "Update beta tag to ${VERSION}"
|
|
||||||
git push origin beta --force
|
|
||||||
|
|
||||||
- name: Update beta release to be latest
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ github.token }}
|
|
||||||
run: |
|
|
||||||
# Update beta release to be marked as latest
|
|
||||||
gh release edit beta --latest
|
|
||||||
|
|
||||||
update-major-tag:
|
|
||||||
needs: create-release
|
|
||||||
if: ${{ !inputs.dry_run }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Update major version tag
|
|
||||||
run: |
|
|
||||||
next_version="${{ needs.create-release.outputs.next_version }}"
|
|
||||||
# Extract major version (e.g., v0 from v0.0.20)
|
|
||||||
major_version=$(echo "$next_version" | cut -d. -f1)
|
|
||||||
|
|
||||||
# Update the major version tag to point to this release
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git tag -fa "$major_version" -m "Update $major_version tag to $next_version"
|
|
||||||
git push origin "$major_version" --force
|
|
||||||
|
|
||||||
echo "Updated $major_version tag to point to $next_version"
|
|
||||||
@@ -50,6 +50,20 @@ Thank you for your interest in contributing to Claude Code Action! This document
|
|||||||
bun test
|
bun test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2. **Integration Tests** (using GitHub Actions locally):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./test-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This script:
|
||||||
|
|
||||||
|
- Installs `act` if not present (requires Homebrew on macOS)
|
||||||
|
- Runs the GitHub Action workflow locally using Docker
|
||||||
|
- Requires your `ANTHROPIC_API_KEY` to be set
|
||||||
|
|
||||||
|
On Apple Silicon Macs, the script automatically adds the `--container-architecture linux/amd64` flag to avoid compatibility issues.
|
||||||
|
|
||||||
## Pull Request Process
|
## Pull Request Process
|
||||||
|
|
||||||
1. Create a new branch from `main`:
|
1. Create a new branch from `main`:
|
||||||
@@ -89,7 +103,13 @@ Thank you for your interest in contributing to Claude Code Action! This document
|
|||||||
|
|
||||||
When modifying the action:
|
When modifying the action:
|
||||||
|
|
||||||
1. Test in a real GitHub Actions workflow by:
|
1. Test locally with the test script:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./test-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Test in a real GitHub Actions workflow by:
|
||||||
- Creating a test repository
|
- Creating a test repository
|
||||||
- Using your branch as the action source:
|
- Using your branch as the action source:
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
45
README.md
45
README.md
@@ -149,40 +149,6 @@ For MCP servers that require sensitive information like API keys or tokens, use
|
|||||||
# ... other inputs
|
# ... other inputs
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using Python MCP Servers with uv
|
|
||||||
|
|
||||||
For Python-based MCP servers managed with `uv`, you need to specify the directory containing your server:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: anthropics/claude-code-action@beta
|
|
||||||
with:
|
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
||||||
mcp_config: |
|
|
||||||
{
|
|
||||||
"mcpServers": {
|
|
||||||
"my-python-server": {
|
|
||||||
"type": "stdio",
|
|
||||||
"command": "uv",
|
|
||||||
"args": [
|
|
||||||
"--directory",
|
|
||||||
"${{ github.workspace }}/path/to/server/",
|
|
||||||
"run",
|
|
||||||
"server_file.py"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
allowed_tools: "my-python-server__<tool_name>" # Replace <tool_name> with your server's tool names
|
|
||||||
# ... other inputs
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, if your Python MCP server is at `mcp_servers/weather.py`, you would use:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
"args":
|
|
||||||
["--directory", "${{ github.workspace }}/mcp_servers/", "run", "weather.py"]
|
|
||||||
```
|
|
||||||
|
|
||||||
**Important**:
|
**Important**:
|
||||||
|
|
||||||
- Always use GitHub Secrets (`${{ secrets.SECRET_NAME }}`) for sensitive values like API keys, tokens, or passwords. Never hardcode secrets directly in the workflow file.
|
- Always use GitHub Secrets (`${{ secrets.SECRET_NAME }}`) for sensitive values like API keys, tokens, or passwords. Never hardcode secrets directly in the workflow file.
|
||||||
@@ -381,15 +347,8 @@ Claude does **not** have access to execute arbitrary Bash commands by default. I
|
|||||||
```yaml
|
```yaml
|
||||||
- uses: anthropics/claude-code-action@beta
|
- uses: anthropics/claude-code-action@beta
|
||||||
with:
|
with:
|
||||||
allowed_tools: |
|
allowed_tools: "Bash(npm install),Bash(npm run test),Edit,Replace,NotebookEditCell"
|
||||||
Bash(npm install)
|
disallowed_tools: "TaskOutput,KillTask"
|
||||||
Bash(npm run test)
|
|
||||||
Edit
|
|
||||||
Replace
|
|
||||||
NotebookEditCell
|
|
||||||
disallowed_tools: |
|
|
||||||
TaskOutput
|
|
||||||
KillTask
|
|
||||||
# ... other inputs
|
# ... other inputs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ runs:
|
|||||||
- name: Run Claude Code
|
- name: Run Claude Code
|
||||||
id: claude-code
|
id: claude-code
|
||||||
if: steps.prepare.outputs.contains_trigger == 'true'
|
if: steps.prepare.outputs.contains_trigger == 'true'
|
||||||
uses: anthropics/claude-code-base-action@56355f77b19f27378aaf141b9b7e08cc43b542f6 # v0.0.23
|
uses: anthropics/claude-code-base-action@ebd8558e902b3db132e89863de49565fcb9aec46 # v0.0.19
|
||||||
with:
|
with:
|
||||||
prompt_file: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
prompt_file: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
||||||
allowed_tools: ${{ env.ALLOWED_TOOLS }}
|
allowed_tools: ${{ env.ALLOWED_TOOLS }}
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
name: Claude Task Executor
|
|
||||||
|
|
||||||
on:
|
|
||||||
repository_dispatch:
|
|
||||||
types: [claude-task]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
|
||||||
issues: write
|
|
||||||
id-token: write # Required for OIDC authentication
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
execute-claude-task:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Execute Claude Task
|
|
||||||
uses: anthropics/claude-code-action@main
|
|
||||||
with:
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# Base branch for creating task branches
|
|
||||||
base_branch: main
|
|
||||||
# Optional: Custom instructions for Claude
|
|
||||||
custom_instructions: |
|
|
||||||
Follow the CLAUDE.md guidelines strictly.
|
|
||||||
Commit changes with descriptive messages.
|
|
||||||
# Optional: Tool restrictions
|
|
||||||
allowed_tools: |
|
|
||||||
file_editor
|
|
||||||
bash_command
|
|
||||||
github_comment
|
|
||||||
mcp__github__create_or_update_file
|
|
||||||
# Optional: Anthropic API configuration
|
|
||||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
||||||
# Or use AWS Bedrock
|
|
||||||
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
||||||
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
||||||
# aws_region: us-east-1
|
|
||||||
# Or use Google Vertex AI
|
|
||||||
# google_credentials: ${{ secrets.GOOGLE_CREDENTIALS }}
|
|
||||||
# vertex_project: my-project
|
|
||||||
# vertex_location: us-central1
|
|
||||||
# Example: Triggering this workflow from another service
|
|
||||||
#
|
|
||||||
# curl -X POST \
|
|
||||||
# https://api.github.com/repos/owner/repo/dispatches \
|
|
||||||
# -H "Authorization: token $GITHUB_TOKEN" \
|
|
||||||
# -H "Accept: application/vnd.github.v3+json" \
|
|
||||||
# -d '{
|
|
||||||
# "event_type": "claude-task",
|
|
||||||
# "client_payload": {
|
|
||||||
# "description": "Analyze the codebase and create a comprehensive test suite for the authentication module",
|
|
||||||
# "progress_endpoint": "https://api.example.com/claude/progress",
|
|
||||||
# "correlation_id": "task-auth-tests-2024-01-17"
|
|
||||||
# }
|
|
||||||
# }'
|
|
||||||
#
|
|
||||||
# The progress_endpoint will receive POST requests with:
|
|
||||||
# {
|
|
||||||
# "repository": "owner/repo",
|
|
||||||
# "run_id": "123456789",
|
|
||||||
# "correlation_id": "task-auth-tests-2024-01-17",
|
|
||||||
# "status": "in_progress" | "completed" | "failed",
|
|
||||||
# "message": "Current progress description",
|
|
||||||
# "completed_tasks": ["task1", "task2"],
|
|
||||||
# "current_task": "Working on task3",
|
|
||||||
# "timestamp": "2024-01-17T12:00:00Z"
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# Authentication: Progress updates include a GitHub OIDC token in the Authorization header
|
|
||||||
118
pr-summary.md
118
pr-summary.md
@@ -1,118 +0,0 @@
|
|||||||
## Summary
|
|
||||||
|
|
||||||
Adds support for `repository_dispatch` events, enabling backend services to programmatically trigger Claude to perform tasks and receive progress updates via API.
|
|
||||||
|
|
||||||
## Architecture
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
sequenceDiagram
|
|
||||||
participant Backend as Backend Service
|
|
||||||
participant GH as GitHub
|
|
||||||
participant Action as Claude Action
|
|
||||||
participant Claude as Claude
|
|
||||||
participant MCP as Progress MCP Server
|
|
||||||
participant API as Progress API
|
|
||||||
|
|
||||||
Backend->>GH: POST /repos/{owner}/{repo}/dispatches
|
|
||||||
Note over Backend,GH: Payload includes:<br/>- description (task)<br/>- progress_endpoint<br/>- correlation_id
|
|
||||||
|
|
||||||
GH->>Action: Trigger workflow<br/>(repository_dispatch)
|
|
||||||
|
|
||||||
Action->>Action: Parse dispatch payload
|
|
||||||
Note over Action: Extract task description,<br/>endpoint, correlation_id
|
|
||||||
|
|
||||||
Action->>MCP: Install Progress Server
|
|
||||||
Note over MCP: Configure with:<br/>- PROGRESS_ENDPOINT<br/>- CORRELATION_ID<br/>- GITHUB_RUN_ID
|
|
||||||
|
|
||||||
Action->>Claude: Execute task with<br/>MCP tools available
|
|
||||||
|
|
||||||
loop Task Execution
|
|
||||||
Claude->>MCP: update_claude_progress()
|
|
||||||
MCP->>MCP: Get OIDC token
|
|
||||||
MCP->>API: POST progress update
|
|
||||||
Note over API: Payload includes:<br/>- correlation_id<br/>- status<br/>- message<br/>- completed_tasks
|
|
||||||
API->>Backend: Forward update
|
|
||||||
end
|
|
||||||
|
|
||||||
Claude->>Action: Task complete
|
|
||||||
Action->>GH: Commit changes
|
|
||||||
```
|
|
||||||
|
|
||||||
## Key Features
|
|
||||||
|
|
||||||
### 1. Repository Dispatch Support
|
|
||||||
|
|
||||||
- New event handler for `repository_dispatch` events
|
|
||||||
- Extracts task description, progress endpoint, and correlation ID from `client_payload`
|
|
||||||
- Bypasses GitHub UI interaction for fully programmatic operation
|
|
||||||
|
|
||||||
### 2. Progress Reporting MCP Server
|
|
||||||
|
|
||||||
- New MCP server (`progress-server.ts`) for sending progress updates
|
|
||||||
- OIDC authentication for secure API communication
|
|
||||||
- Includes correlation ID in all updates for request tracking
|
|
||||||
|
|
||||||
### 3. Simplified Dispatch Prompts
|
|
||||||
|
|
||||||
- Focused instructions for dispatch events (no PR/issue context)
|
|
||||||
- Clear directives: answer questions or implement changes
|
|
||||||
- Automatic progress updates at start and completion
|
|
||||||
|
|
||||||
## Implementation Details
|
|
||||||
|
|
||||||
### Triggering a Dispatch
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -X POST \
|
|
||||||
https://api.github.com/repos/{owner}/{repo}/dispatches \
|
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
|
||||||
-d '{
|
|
||||||
"event_type": "claude-task",
|
|
||||||
"client_payload": {
|
|
||||||
"description": "Implement a new feature that...",
|
|
||||||
"progress_endpoint": "https://api.example.com/progress",
|
|
||||||
"correlation_id": "req-123-abc"
|
|
||||||
}
|
|
||||||
}'
|
|
||||||
```
|
|
||||||
|
|
||||||
### Progress Update Payload
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"repository": "owner/repo",
|
|
||||||
"run_id": "123456789",
|
|
||||||
"correlation_id": "req-123-abc",
|
|
||||||
"status": "in_progress",
|
|
||||||
"message": "Implementing feature...",
|
|
||||||
"completed_tasks": ["Setup environment", "Created base structure"],
|
|
||||||
"current_task": "Writing tests",
|
|
||||||
"timestamp": "2024-01-17T12:00:00Z"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
- **OIDC Authentication**: All progress updates use GitHub OIDC tokens
|
|
||||||
- **Correlation IDs**: Included in request body (not URL) for security
|
|
||||||
- **Endpoint Validation**: Progress endpoint must be explicitly provided
|
|
||||||
- **No Credential Storage**: Tokens are generated per-request
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
To test the repository_dispatch flow:
|
|
||||||
|
|
||||||
1. Configure workflow with `repository_dispatch` trigger
|
|
||||||
2. Send dispatch event with required payload
|
|
||||||
3. Monitor GitHub Actions logs for execution
|
|
||||||
4. Verify progress updates at configured endpoint
|
|
||||||
|
|
||||||
## Changes
|
|
||||||
|
|
||||||
- Added `repository_dispatch` event handling in `context.ts`
|
|
||||||
- Created new `progress-server.ts` MCP server
|
|
||||||
- Updated `isDispatch` flag across all event types
|
|
||||||
- Modified prompt generation for dispatch events
|
|
||||||
- Made `githubData` optional for dispatch workflows
|
|
||||||
- Added correlation ID support throughout the pipeline
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import * as github from "@actions/github";
|
import * as github from "@actions/github";
|
||||||
import type {
|
import type {
|
||||||
IssuesEvent,
|
IssuesEvent,
|
||||||
IssuesAssignedEvent,
|
|
||||||
IssueCommentEvent,
|
IssueCommentEvent,
|
||||||
PullRequestEvent,
|
PullRequestEvent,
|
||||||
PullRequestReviewEvent,
|
PullRequestReviewEvent,
|
||||||
@@ -53,8 +52,14 @@ export function parseGitHubContext(): ParsedGitHubContext {
|
|||||||
inputs: {
|
inputs: {
|
||||||
triggerPhrase: process.env.TRIGGER_PHRASE ?? "@claude",
|
triggerPhrase: process.env.TRIGGER_PHRASE ?? "@claude",
|
||||||
assigneeTrigger: process.env.ASSIGNEE_TRIGGER ?? "",
|
assigneeTrigger: process.env.ASSIGNEE_TRIGGER ?? "",
|
||||||
allowedTools: parseMultilineInput(process.env.ALLOWED_TOOLS ?? ""),
|
allowedTools: (process.env.ALLOWED_TOOLS ?? "")
|
||||||
disallowedTools: parseMultilineInput(process.env.DISALLOWED_TOOLS ?? ""),
|
.split(",")
|
||||||
|
.map((tool) => tool.trim())
|
||||||
|
.filter((tool) => tool.length > 0),
|
||||||
|
disallowedTools: (process.env.DISALLOWED_TOOLS ?? "")
|
||||||
|
.split(",")
|
||||||
|
.map((tool) => tool.trim())
|
||||||
|
.filter((tool) => tool.length > 0),
|
||||||
customInstructions: process.env.CUSTOM_INSTRUCTIONS ?? "",
|
customInstructions: process.env.CUSTOM_INSTRUCTIONS ?? "",
|
||||||
directPrompt: process.env.DIRECT_PROMPT ?? "",
|
directPrompt: process.env.DIRECT_PROMPT ?? "",
|
||||||
baseBranch: process.env.BASE_BRANCH,
|
baseBranch: process.env.BASE_BRANCH,
|
||||||
@@ -111,14 +116,6 @@ export function parseGitHubContext(): ParsedGitHubContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseMultilineInput(s: string): string[] {
|
|
||||||
return s
|
|
||||||
.split(/,|[\n\r]+/)
|
|
||||||
.map((tool) => tool.replace(/#.+$/, ""))
|
|
||||||
.map((tool) => tool.trim())
|
|
||||||
.filter((tool) => tool.length > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isIssuesEvent(
|
export function isIssuesEvent(
|
||||||
context: ParsedGitHubContext,
|
context: ParsedGitHubContext,
|
||||||
): context is ParsedGitHubContext & { payload: IssuesEvent } {
|
): context is ParsedGitHubContext & { payload: IssuesEvent } {
|
||||||
@@ -148,9 +145,3 @@ export function isPullRequestReviewCommentEvent(
|
|||||||
): context is ParsedGitHubContext & { payload: PullRequestReviewCommentEvent } {
|
): context is ParsedGitHubContext & { payload: PullRequestReviewCommentEvent } {
|
||||||
return context.eventName === "pull_request_review_comment";
|
return context.eventName === "pull_request_review_comment";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIssuesAssignedEvent(
|
|
||||||
context: ParsedGitHubContext,
|
|
||||||
): context is ParsedGitHubContext & { payload: IssuesAssignedEvent } {
|
|
||||||
return isIssuesEvent(context) && context.eventAction === "assigned";
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import {
|
import {
|
||||||
isIssuesEvent,
|
isIssuesEvent,
|
||||||
isIssuesAssignedEvent,
|
|
||||||
isIssueCommentEvent,
|
isIssueCommentEvent,
|
||||||
isPullRequestEvent,
|
isPullRequestEvent,
|
||||||
isPullRequestReviewEvent,
|
isPullRequestReviewEvent,
|
||||||
@@ -23,10 +22,10 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for assignee trigger
|
// Check for assignee trigger
|
||||||
if (isIssuesAssignedEvent(context)) {
|
if (isIssuesEvent(context) && context.eventAction === "assigned") {
|
||||||
// Remove @ symbol from assignee_trigger if present
|
// Remove @ symbol from assignee_trigger if present
|
||||||
let triggerUser = assigneeTrigger.replace(/^@/, "");
|
let triggerUser = assigneeTrigger.replace(/^@/, "");
|
||||||
const assigneeUsername = context.payload.assignee?.login || "";
|
const assigneeUsername = context.payload.issue.assignee?.login || "";
|
||||||
|
|
||||||
if (triggerUser && assigneeUsername === triggerUser) {
|
if (triggerUser && assigneeUsername === triggerUser) {
|
||||||
console.log(`Issue assigned to trigger user '${triggerUser}'`);
|
console.log(`Issue assigned to trigger user '${triggerUser}'`);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export async function prepareMcpConfig(
|
|||||||
"--rm",
|
"--rm",
|
||||||
"-e",
|
"-e",
|
||||||
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
"GITHUB_PERSONAL_ACCESS_TOKEN",
|
||||||
"ghcr.io/github/github-mcp-server:sha-6d69797", // https://github.com/github/github-mcp-server/releases/tag/v0.5.0
|
"ghcr.io/github/github-mcp-server:sha-e9f748f", // https://github.com/github/github-mcp-server/releases/tag/v0.4.0
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
GITHUB_PERSONAL_ACCESS_TOKEN: githubToken,
|
GITHUB_PERSONAL_ACCESS_TOKEN: githubToken,
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
import { describe, it, expect } from "bun:test";
|
|
||||||
import { parseMultilineInput } from "../../src/github/context";
|
|
||||||
|
|
||||||
describe("parseMultilineInput", () => {
|
|
||||||
it("should parse a comma-separated string", () => {
|
|
||||||
const input = `Bash(bun install),Bash(bun test:*),Bash(bun typecheck)`;
|
|
||||||
const result = parseMultilineInput(input);
|
|
||||||
expect(result).toEqual([
|
|
||||||
"Bash(bun install)",
|
|
||||||
"Bash(bun test:*)",
|
|
||||||
"Bash(bun typecheck)",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should parse multiline string", () => {
|
|
||||||
const input = `Bash(bun install)
|
|
||||||
Bash(bun test:*)
|
|
||||||
Bash(bun typecheck)`;
|
|
||||||
const result = parseMultilineInput(input);
|
|
||||||
expect(result).toEqual([
|
|
||||||
"Bash(bun install)",
|
|
||||||
"Bash(bun test:*)",
|
|
||||||
"Bash(bun typecheck)",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should parse comma-separated multiline line", () => {
|
|
||||||
const input = `Bash(bun install),Bash(bun test:*)
|
|
||||||
Bash(bun typecheck)`;
|
|
||||||
const result = parseMultilineInput(input);
|
|
||||||
expect(result).toEqual([
|
|
||||||
"Bash(bun install)",
|
|
||||||
"Bash(bun test:*)",
|
|
||||||
"Bash(bun typecheck)",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should ignore comments", () => {
|
|
||||||
const input = `Bash(bun install),
|
|
||||||
Bash(bun test:*) # For testing
|
|
||||||
# For type checking
|
|
||||||
Bash(bun typecheck)
|
|
||||||
`;
|
|
||||||
const result = parseMultilineInput(input);
|
|
||||||
expect(result).toEqual([
|
|
||||||
"Bash(bun install)",
|
|
||||||
"Bash(bun test:*)",
|
|
||||||
"Bash(bun typecheck)",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should parse an empty string", () => {
|
|
||||||
const input = "";
|
|
||||||
const result = parseMultilineInput(input);
|
|
||||||
expect(result).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -91,12 +91,6 @@ export const mockIssueAssignedContext: ParsedGitHubContext = {
|
|||||||
actor: "admin-user",
|
actor: "admin-user",
|
||||||
payload: {
|
payload: {
|
||||||
action: "assigned",
|
action: "assigned",
|
||||||
assignee: {
|
|
||||||
login: "claude-bot",
|
|
||||||
id: 11111,
|
|
||||||
avatar_url: "https://avatars.githubusercontent.com/u/11111",
|
|
||||||
html_url: "https://github.com/claude-bot",
|
|
||||||
},
|
|
||||||
issue: {
|
issue: {
|
||||||
number: 123,
|
number: 123,
|
||||||
title: "Feature: Add dark mode support",
|
title: "Feature: Add dark mode support",
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ describe("checkContainsTrigger", () => {
|
|||||||
...mockIssueAssignedContext,
|
...mockIssueAssignedContext,
|
||||||
payload: {
|
payload: {
|
||||||
...mockIssueAssignedContext.payload,
|
...mockIssueAssignedContext.payload,
|
||||||
assignee: {
|
|
||||||
...(mockIssueAssignedContext.payload as IssuesAssignedEvent)
|
|
||||||
.assignee,
|
|
||||||
login: "otherUser",
|
|
||||||
},
|
|
||||||
issue: {
|
issue: {
|
||||||
...(mockIssueAssignedContext.payload as IssuesAssignedEvent).issue,
|
...(mockIssueAssignedContext.payload as IssuesAssignedEvent).issue,
|
||||||
assignee: {
|
assignee: {
|
||||||
|
|||||||
Reference in New Issue
Block a user