Skip to content

Commit 136950f

Browse files
committed
feat: add GitHub Action for issue comment commands
Implements a GitHub Action that responds to /mycoder pr and /mycoder plan commands in issue comments. This allows users to trigger MyCoder directly from GitHub issues. Closes #162.
1 parent c82916c commit 136950f

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: MyCoder Issue Comment Action
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
issues: write
10+
pull-requests: write
11+
12+
env:
13+
PNPM_VERSION: 10.2.1
14+
15+
jobs:
16+
process-comment:
17+
runs-on: ubuntu-latest
18+
if: contains(github.event.comment.body, '/mycoder pr') || contains(github.event.comment.body, '/mycoder plan')
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Set up pnpm
24+
uses: pnpm/action-setup@v2
25+
with:
26+
version: ${{ env.PNPM_VERSION }}
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version-file: .nvmrc
32+
cache: 'pnpm'
33+
34+
- name: Install MyCoder
35+
run: pnpm install -g mycoder
36+
37+
- name: Run MyCoder PR command
38+
if: contains(github.event.comment.body, '/mycoder pr')
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
42+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
43+
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
44+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
45+
run: |
46+
echo "Running MyCoder to implement PR for issue #${{ github.event.issue.number }}"
47+
mycoder --githubMode true "Implement a PR for GitHub issue #${{ github.event.issue.number }}. The issue can be found at ${{ github.event.issue.html_url }}. Please review the issue details and implement a solution according to the requirements. After implementation, create a pull request that addresses this issue."
48+
49+
- name: Run MyCoder Plan command
50+
if: contains(github.event.comment.body, '/mycoder plan')
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
54+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
55+
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
56+
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
57+
run: |
58+
echo "Running MyCoder to create implementation plan for issue #${{ github.event.issue.number }}"
59+
mycoder --githubMode true "Review GitHub issue #${{ github.event.issue.number }} at ${{ github.event.issue.html_url }} and create an implementation plan. Post your plan as a comment on the issue. Be thorough and consider all requirements mentioned in the issue description."

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ mycoder -f prompt.txt
3838
mycoder config set githubMode true
3939
```
4040

41+
### GitHub Comment Commands
42+
43+
MyCoder can be triggered directly from GitHub issue comments using special commands:
44+
45+
- `/mycoder pr` - Implements a PR for the given issue
46+
- `/mycoder plan` - Generates an implementation plan as a comment
47+
48+
[Learn more about GitHub comment commands](docs/github-comment-commands.md)
49+
4150
## Packages
4251

4352
- [mycoder](packages/cli) - Command-line interface for MyCoder

docs/github-comment-commands.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# GitHub Comment Commands
2+
3+
MyCoder provides automated actions in response to specific commands in GitHub issue comments. This feature allows you to trigger MyCoder directly from GitHub issues.
4+
5+
## Available Commands
6+
7+
### `/mycoder pr`
8+
9+
When you add a comment with `/mycoder pr` to any issue, MyCoder will:
10+
11+
1. Check out the repository
12+
2. Review the issue details
13+
3. Implement a solution according to the requirements
14+
4. Create a pull request that addresses the issue
15+
16+
Example:
17+
```
18+
This looks like a great feature to add!
19+
20+
/mycoder pr
21+
```
22+
23+
### `/mycoder plan`
24+
25+
When you add a comment with `/mycoder plan` to any issue, MyCoder will:
26+
27+
1. Review the issue details
28+
2. Create a comprehensive implementation plan
29+
3. Post the plan as a comment on the issue
30+
31+
Example:
32+
```
33+
I'm not sure about the best approach for this.
34+
35+
/mycoder plan
36+
```
37+
38+
## How It Works
39+
40+
This functionality is implemented as a GitHub Action that runs whenever a new comment is added to an issue. The action checks for these specific command patterns and triggers MyCoder with the appropriate instructions.
41+
42+
## Requirements
43+
44+
For this feature to work in your repository:
45+
46+
1. The GitHub Action workflow must be present in your repository
47+
2. You need to configure the necessary API keys as GitHub secrets:
48+
- `GITHUB_TOKEN` (automatically provided)
49+
- `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `XAI_API_KEY`, or `MISTRAL_API_KEY` (depending on your preferred model)
50+
51+
## Limitations
52+
53+
- The action runs with GitHub's default timeout limits
54+
- Complex implementations may require multiple iterations
55+
- The AI model's capabilities determine the quality of the implementation or plan

0 commit comments

Comments
 (0)