Skip to content

Commit 291acd4

Browse files
committed
Update GitHub Actions workflow by standardising GitHub token reference and adding a step to generate prompts from GitHub context, enhancing functionality and clarity.
1 parent 97605c6 commit 291acd4

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

.github/actions/claude-code-action/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ runs:
5555
"ghcr.io/github/github-mcp-server:sha-ff3036d"
5656
],
5757
"env": {
58-
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ inputs.GITHUB_TOKEN }}"
58+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${{ inputs.github_token }}"
5959
}
6060
}'
6161

.github/workflows/claude.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,49 @@ jobs:
2929
with:
3030
fetch-depth: 1
3131

32+
- name: Generate Prompt from GitHub Context
33+
id: generate-prompt
34+
run: |
35+
mkdir -p /tmp/claude-prompts
36+
37+
# Extract the user's request from the GitHub event
38+
if [[ "${{ github.event_name }}" == "issue_comment" ]]; then
39+
PROMPT_TEXT="${{ github.event.comment.body }}"
40+
CONTEXT="Issue Comment: ${{ github.event.issue.title }}"
41+
elif [[ "${{ github.event_name }}" == "pull_request_review_comment" ]]; then
42+
PROMPT_TEXT="${{ github.event.comment.body }}"
43+
CONTEXT="PR Comment: ${{ github.event.pull_request.title }}"
44+
elif [[ "${{ github.event_name }}" == "pull_request_review" ]]; then
45+
PROMPT_TEXT="${{ github.event.review.body }}"
46+
CONTEXT="PR Review: ${{ github.event.pull_request.title }}"
47+
elif [[ "${{ github.event_name }}" == "issues" ]]; then
48+
PROMPT_TEXT="${{ github.event.issue.body }}"
49+
CONTEXT="Issue: ${{ github.event.issue.title }}"
50+
fi
51+
52+
# Create the prompt file
53+
cat > /tmp/claude-prompts/github-context-prompt.txt << EOF
54+
You are Claude Code, an AI assistant that helps with code and GitHub workflows.
55+
56+
Context: $CONTEXT
57+
Repository: ${{ github.repository }}
58+
59+
User Request:
60+
$PROMPT_TEXT
61+
62+
Please analyze the request and provide helpful assistance. You have access to the repository context and can help with code analysis, suggestions, and implementations.
63+
EOF
64+
65+
echo "prompt_file=/tmp/claude-prompts/github-context-prompt.txt" >> $GITHUB_OUTPUT
66+
shell: bash
67+
3268
- name: Run Claude Code
3369
id: claude
3470
uses: ./.github/actions/claude-code-action
3571
with:
72+
prompt_file: ${{ steps.generate-prompt.outputs.prompt_file }}
73+
install_github_mcp: "true"
74+
timeout_minutes: "10"
3675
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
3776
github_token: ${{ secrets.GITHUB_TOKEN }}
3877

0 commit comments

Comments
 (0)