- Notifications
You must be signed in to change notification settings - Fork948
docs: add GitHub Actions integration for AI agents#18845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
blink-so wants to merge2 commits intomainChoose a base branch fromdocs/add-github-actions-ai-integration
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
187 changes: 187 additions & 0 deletionsdocs/ai-coder/github-actions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
# GitHub Actions Integration | ||
Coder provides a GitHub Action that automatically starts workspaces from GitHub issues and comments, enabling seamless integration between your development workflow and AI coding agents. | ||
## Start Workspace Action | ||
The [start-workspace-action](https://github.com/coder/start-workspace-action) creates Coder workspaces triggered by GitHub events and posts status updates directly to GitHub issues. | ||
### Features | ||
- **Automatic workspace creation** from GitHub issues or comments | ||
- **Real-time status updates** posted as GitHub issue comments | ||
- **User mapping** between GitHub and Coder accounts | ||
- **Configurable triggers** based on your workflow requirements | ||
- **Template parameters** for customizing workspace environments | ||
### Basic Usage | ||
Here's an example workflow that starts a workspace when issues are created or when comments contain "@coder": | ||
```yaml | ||
name: Start Workspace On Issue Creation or Comment | ||
on: | ||
issues: | ||
types: [opened] | ||
issue_comment: | ||
types: [created] | ||
permissions: | ||
issues: write | ||
jobs: | ||
start-workspace: | ||
runs-on: ubuntu-latest | ||
if: > | ||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@coder')) || | ||
(github.event_name == 'issues' && contains(github.event.issue.body, '@coder')) | ||
environment: coder-production | ||
timeout-minutes: 5 | ||
steps: | ||
- name: Start Coder workspace | ||
uses: coder/start-workspace-action@v0.1.0 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
github-username: > | ||
${{ | ||
(github.event_name == 'issue_comment' && github.event.comment.user.login) || | ||
(github.event_name == 'issues' && github.event.issue.user.login) | ||
}} | ||
coder-url: ${{ secrets.CODER_URL }} | ||
coder-token: ${{ secrets.CODER_TOKEN }} | ||
template-name: ${{ secrets.CODER_TEMPLATE_NAME }} | ||
parameters: |- | ||
Coder Image: codercom/oss-dogfood:latest | ||
Coder Repository Base Directory: "~" | ||
AI Code Prompt: "Use the gh CLI tool to read the details of issue https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }} and then address it." | ||
Region: us-pittsburgh | ||
``` | ||
### Configuration | ||
#### Required Inputs | ||
| Input | Description | | ||
|-----------------|-------------------------------------------------| | ||
| `coder-url` | Your Coder deployment URL | | ||
| `coder-token` | API token for Coder (requires admin privileges) | | ||
| `template-name` | Name of the Coder template to use | | ||
| `parameters` | YAML-formatted parameters for the workspace | | ||
#### Optional Inputs | ||
| Input | Description | Default | | ||
|-----------------------|-------------------------------------------------|----------------------------| | ||
| `github-token` | GitHub token for posting comments | `${{ github.token }}` | | ||
| `github-issue-number` | Issue number for status comments | Current issue from context | | ||
| `github-username` | GitHub user to map to Coder user | - | | ||
| `coder-username` | Coder username (alternative to github-username) | - | | ||
| `workspace-name` | Name for the new workspace | `issue-{issue_number}` | | ||
### User Mapping | ||
The action supports two methods for mapping users: | ||
1. **GitHub Username Mapping** (Coder 2.21+): Set `github-username` to automatically map GitHub users to Coder users who have logged in with the same GitHub account. | ||
2. **Direct Coder Username**: Set `coder-username` to specify the exact Coder user. | ||
### Security Best Practices | ||
Since this action requires a Coder admin API token, follow these security recommendations: | ||
1. **Use GitHub Environments**: Store sensitive secrets in a GitHub environment (e.g., "coder-production") | ||
2. **Restrict Branch Access**: Limit the environment to specific branches (e.g., main) | ||
3. **Minimal Permissions**: Use the least privileged token possible | ||
```yaml | ||
jobs: | ||
start-workspace: | ||
runs-on: ubuntu-latest | ||
# Restrict access to secrets using environments | ||
environment: coder-production | ||
steps: | ||
- name: Start Coder workspace | ||
uses: coder/start-workspace-action@v0.1.0 | ||
with: | ||
coder-token: ${{ secrets.CODER_TOKEN }} | ||
# other inputs... | ||
``` | ||
### AI Agent Integration | ||
This action works particularly well with AI coding agents by: | ||
- **Providing context**: Pass issue details to agents via template parameters | ||
- **Automating setup**: Pre-configure workspaces with necessary tools and repositories | ||
- **Enabling collaboration**: Allow agents to work on issues triggered by team members | ||
#### Example AI Agent Prompt | ||
```yaml | ||
parameters: |- | ||
AI Code Prompt: | | ||
You are an AI coding assistant. Your task is to: | ||
1. Read the GitHub issue at https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }} | ||
2. Analyze the requirements and existing codebase | ||
3. Implement the requested changes | ||
4. Run tests to ensure functionality | ||
5. Create a pull request with your solution | ||
``` | ||
### Workflow Examples | ||
#### Issue-Triggered Workspaces | ||
```yaml | ||
on: | ||
issues: | ||
types: [opened, labeled] | ||
jobs: | ||
start-workspace: | ||
if: contains(github.event.issue.labels.*.name, 'ai-assist') | ||
# ... rest of configuration | ||
``` | ||
#### Comment-Triggered Workspaces | ||
```yaml | ||
on: | ||
issue_comment: | ||
types: [created] | ||
jobs: | ||
start-workspace: | ||
if: | | ||
github.event.issue.pull_request == null && | ||
contains(github.event.comment.body, '/coder start') | ||
# ... rest of configuration | ||
``` | ||
### Requirements | ||
- Coder deployment with API access | ||
- Coder 2.21+ for GitHub username mapping (earlier versions can use `coder-username`) | ||
- GitHub repository with appropriate secrets configured | ||
- Coder template configured for AI agent workflows | ||
### Troubleshooting | ||
#### Common Issues | ||
- **Authentication failures**: Ensure `CODER_TOKEN` has admin privileges | ||
- **User mapping errors**: Verify GitHub users have logged into Coder with the same account | ||
- **Template not found**: Check that `template-name` exists and is accessible | ||
- **Parameter validation**: Ensure template parameters match expected format | ||
#### GitHub Enterprise | ||
This action supports GitHub Enterprise with the exception of the `github-username` input. Use `coder-username` instead for GitHub Enterprise deployments. | ||
## Next Steps | ||
- [Configure Coder Tasks](./tasks.md) for running AI agents | ||
- [Set up custom agents](./custom-agents.md) in your templates | ||
- [Review security considerations](./security.md) for AI agent deployments |
4 changes: 4 additions & 0 deletionsdocs/ai-coder/index.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionsdocs/manifest.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.