This repository contains GitHub Actions workflows that automatically generate pull requests using Aider in response to issues labeled with 'aider'.
- When an issue is labeled with 'aider' 🏷️, the workflow is triggered
- 🌿 A new feature branch is created based on the issue title
- 🤖 Aider processes the issue description as instructions and makes the requested changes
- ✨ The changes are committed and a pull request can be created
-
Configure one or more of the following API keys as repository secrets:
OPENAI_API_KEYANTHROPIC_API_KEYGEMINI_API_KEYGROQ_API_KEYCOHERE_API_KEYDEEPSEEK_API_KEYOPENROUTER_API_KEY
-
Create a GitHub Personal Access Token (PAT) with
reposcope and add it as a repository secret namedGH_TOKEN. This token is required for:- Creating branches
- Committing changes
- Creating pull requests
- Other GitHub API operations
-
The workflow will be triggered when you add the
aiderlabel to any issue
Create a workflow file at .github/workflows/aider.yml:
name: Aider Issue Handler
on:
issues:
types: [labeled]
jobs:
handle-labeled-issue:
if: github.event.label.name == 'aider'
uses: ./.github/workflows/aider-issue.yml
with:
base-branch: main # or your default branch
chat-timeout: 10 # timeout in minutes
model: gpt-4-1106-preview # or your preferred model
issue-number: ${{ github.event.issue.number }}
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
# Add other API keys as needed:
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
# groq_api_key: ${{ secrets.GROQ_API_KEY }}
# cohere_api_key: ${{ secrets.COHERE_API_KEY }}
# deepseek_api_key: ${{ secrets.DEEPSEEK_API_KEY }}
# openrouter_api_key: ${{ secrets.OPENROUTER_API_KEY }}name: Auto-generate PR using Aider
on:
issues:
types: [labeled]
permissions:
issues: write
contents: write
pull-requests: write
jobs:
generate:
uses: javeoff/aider-github-actions/.github/workflows/aider-issue.yml@main
if: github.event.label.name == 'aider'
with:
issue-number: ${{ github.event.issue.number }}
base-branch: ${{ github.event.repository.default_branch }}
model: openrouter/anthropic/claude-3.5-sonnet
secrets:
openrouter_api_key: ${{ secrets.OPENROUTER_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}This workflow will trigger when an issue is labeled with 'aider' and use the reusable workflow to process the issue.
name: Auto-generate PR using Aider
on:
issues:
types: [labeled]
permissions:
issues: write
contents: write
pull-requests: write
jobs:
generate:
uses: javeoff/aider-github-actions/.github/workflows/aider-issue.yml@main
if: github.event.label.name == 'aider'
with:
issue-number: ${{ github.event.issue.number }}
base-branch: ${{ github.event.repository.default_branch }}
model: gpt-4-1106-preview
custom-aider-args: '--no-auto-commits --skip-steps' # Custom Aider arguments
secrets:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}This example shows how to pass custom arguments to Aider using the custom-aider-args parameter. You can use any valid Aider command-line arguments.
The action supports multiple AI providers through their respective API keys:
- OpenAI (GPT-4, GPT-3.5)
- Anthropic (Claude)
- Google (Gemini)
- Groq
- Cohere
- DeepSeek
- OpenRouter (access to multiple models)
Configure the desired model using the model input parameter and provide the corresponding API key as a secret.
The main workflow can be customized through the following inputs:
base-branch: Base branch to create PR against (default: repository's default branch)chat-timeout: Timeout for chat in minutes (default: 10)model: AI model to use (default: gpt-4-1106-preview)issue-number: Issue number to process (required for issue workflow)pr-number: PR number to process (required for PR comment workflow)custom-aider-args: Additional arguments to pass to Aider (optional)
- Create an issue describing the changes you want to make
- Add the
aiderlabel to the issue - The workflow will create a new branch and apply the requested changes
- Review the changes and create a pull request if desired
You can also use Aider to make changes by commenting on pull requests. When you add a comment starting with /aider on a PR, the workflow will:
- Process your instructions
- Make the requested changes
- Commit them to the PR branch
Example comment:
/aider Please add error handling to this function
Here's a sample issue that demonstrates how to use the GitHub Aider Action:
"Update error handling in login.js"
Please improve the error handling in login.js:
1. Add try/catch blocks around the database queries
2. Show user-friendly error messages
3. Add logging for debugging
When you add the aider label to this issue:
- A new branch named
update-error-handling-in-login-jswill be created - Aider will process these instructions and make the requested changes
- The changes will be committed to the branch
- You can then review and create a PR with the changes
The more specific and clear your issue description is, the better results you'll get from Aider.
The workflow saves the Aider chat history as an artifact that can be downloaded from the workflow run page.