copilot-cli-actions
Search for examples on GitHub "copilot -p" path:.github/workflows/*.yml
You need to use fine-grained personal access tokens for now New fine-grained personal access token
GitHub Copilot CLI Action 🤖
A GitHub Action wrapper for the GitHub Copilot CLI that enables AI-powered automation in your CI/CD workflows.
Installation
Token
Create a new fine-grained personal access token
Basic Setup
Add the following workflow to your .github/workflows folder:
name: 'Copilot Automation' on: pull_request: jobs: copilot-task: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: 'Run Copilot CLI' uses: austenstone/copilot-cli-actions@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} prompt: 'Analyze this pull request and provide feedback on code quality'
Advanced Setup with MCP Servers
name: 'Advanced Copilot Automation' on: [issues, pull_request] jobs: copilot-advanced: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' uses: actions/checkout@v4 - name: 'Run Copilot with Custom Config' uses: austenstone/copilot-cli-actions@v1 with: github-token: ${{ secrets.COPILOT_TOKEN }} prompt: | Review this pull request for: 1. Code quality and best practices 2. Security vulnerabilities 3. Performance implications 4. Documentation completeness model: 'claude-sonnet-4.5' allow-all-tools: true mcp-config: | { "mcpServers": { "custom-api": { "type": "http", "url": "https://api.example.com/mcp", "headers": { "Authorization": "Bearer ${{ secrets.API_TOKEN }}" } } } }
Configuration
Input Parameters
| Parameter | Description | Required | Default |
|---|---|---|---|
github-token | GitHub Personal Access Token with required permissions | ✅ | - |
prompt | Natural language prompt to send to GitHub Copilot | ✅ | - |
mcp-config | MCP server configuration in JSON format | ❌ | {} |
copilot-config | GitHub Copilot CLI configuration | ❌ | See below |
log-level | Logging verbosity level | ❌ | all |
allow-all-tools | Allow all tools without approval | ❌ | true |
denied-tools | Comma-separated list of tools to deny | ❌ | '' |
copilot-version | Version of @github/copilot to install | ❌ | latest |
model | AI model to use | ❌ | '' |
additional-directories | Additional directories to trust for file access | ❌ | '' |
disable-mcp-servers | MCP servers to disable | ❌ | '' |
no-color | Disable color output | ❌ | true |
screen-reader | Enable screen reader optimizations | ❌ | false |
resume-session | Resume from previous session | ❌ | '' |
show-banner | Show animated startup banner | ❌ | false |
upload-artifact | Upload logs and trajectory as artifacts | ❌ | true |
Default Copilot Configuration
{
"banner": "never",
"render_markdown": true,
"theme": "auto",
"trusted_folders": []
}MCP Server Configuration
The action supports Model Context Protocol (MCP) servers for extending Copilot's capabilities:
mcp-config: | { "mcpServers": { "database-server": { "type": "http", "url": "https://your-db-mcp-server.com", "headers": { "Authorization": "Bearer ${{ secrets.DB_TOKEN }}" }, "tools": ["query_db", "update_schema"] }, "context7": { "type": "http", "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "YOUR_API_KEY" }, "tools": ["get-library-docs", "resolve-library-id"] } } }
Model Selection
Supported models include:
-
claude-sonnet-4.5(recommended) claude-sonnet-4gpt-5gpt-4o
Outputs
The action provides several outputs that can be used by subsequent steps:
| Output | Description |
|---|---|
trajectory-path | Path to the trajectory markdown file containing the full interaction log |
logs-path | Path to the copilot logs directory |
exit-code | Exit code from the Copilot CLI command (0 = success) |
Examples
Code Review Automation
name: 'AI Code Review' on: pull_request: types: [opened, synchronize] jobs: ai-review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: austenstone/copilot-cli-actions@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} prompt: | Please review this pull request and: 1. Check for potential bugs or security issues 2. Suggest improvements for code quality 3. Verify that tests cover the new functionality 4. Comment on the PR with your findings model: 'claude-sonnet-4.5'
Issue Triage and Labeling
name: 'AI Issue Triage' on: issues: types: [opened] jobs: triage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: austenstone/copilot-cli-actions@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} prompt: | Analyze this new issue and: 1. Categorize it (bug, feature, documentation, etc.) 2. Estimate complexity/priority 3. Add appropriate labels 4. Suggest potential assignees based on the codebase
Documentation Generation
name: 'Generate Documentation' on: push: branches: [main] paths: ['src/**/*.ts', 'src/**/*.js'] jobs: docs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: austenstone/copilot-cli-actions@v1 with: github-token: ${{ secrets.GITHUB_TOKEN }} prompt: | Update the README.md file to reflect any API changes in the recent commits. Focus on: 1. New functions and classes 2. Changed method signatures 3. Updated usage examples 4. Breaking changes
Troubleshooting
Common Issues
-
Permission Denied Errors
- Ensure your GitHub token has the required permissions
- Check that the token hasn't expired
-
Tool Access Denied
- Review your
denied-toolsconfiguration - Consider setting
allow-all-tools: falsefor better security
- Review your
-
MCP Server Connection Issues
- Verify MCP server URLs are accessible
- Check authentication headers and tokens
-
Large Output Truncation
- Use
no-color: trueto reduce output size - Consider breaking complex prompts into smaller tasks
- Use
Debug Mode
Enable detailed logging by setting:
log-level: 'debug' no-color: false
Contributing
We welcome contributions! Please see our contributing guidelines for details on:
- Reporting bugs
- Suggesting enhancements
- Submitting pull requests
- Code style requirements
License
This project is licensed under the MIT License.
0 commit comments