opencode / packages /web /src /content /docs /ko /github.mdx
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
0dbc9de verified
Raw
History Blame Contribute Delete
11.6 kB
---
title: GitHub
description: GitHub issue์™€ pull request์—์„œ OpenCode๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.
---
OpenCode๋Š” GitHub ์›Œํฌํ”Œ๋กœ์™€ ํ†ตํ•ฉ๋ฉ๋‹ˆ๋‹ค. ๋Œ“๊ธ€์— `/opencode` ๋˜๋Š” `/oc`๋ฅผ mentionํ•˜๋ฉด OpenCode๊ฐ€ GitHub Actions runner ์•ˆ์—์„œ ์ž‘์—…์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
---
## ๊ธฐ๋Šฅ
- **Issue triage**: OpenCode์—๊ฒŒ issue๋ฅผ ๋ถ„์„ํ•˜๊ณ  ๋‚ด์šฉ์„ ์„ค๋ช…ํ•˜๋„๋ก ์š”์ฒญํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
- **Fix and implement**: OpenCode์—๊ฒŒ issue ์ˆ˜์ •์ด๋‚˜ ๊ธฐ๋Šฅ ๊ตฌํ˜„์„ ์š”์ฒญํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ƒˆ branch์—์„œ ์ž‘์—…ํ•œ ๋’ค ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ๋‹ด์€ PR์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
- **Secure**: OpenCode๋Š” GitHub runner ๋‚ด๋ถ€์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.
---
## ์„ค์น˜
GitHub repo์— ์—ฐ๊ฒฐ๋œ ํ”„๋กœ์ ํŠธ์—์„œ ์•„๋ž˜ ๋ช…๋ น์„ ์‹คํ–‰ํ•˜์„ธ์š”.
```bash
opencode github install
```
์ด ๋ช…๋ น์€ GitHub app ์„ค์น˜, workflow ์ƒ์„ฑ, secrets ์„ค์ • ๊ณผ์ •์„ ์•ˆ๋‚ดํ•ฉ๋‹ˆ๋‹ค.
---
### Manual Setup
์›ํ•˜๋ฉด ์ˆ˜๋™์œผ๋กœ๋„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
1. **Install the GitHub app**
[**github.com/apps/opencode-agent**](https://github.com/apps/opencode-agent)๋กœ ์ด๋™ํ•˜์„ธ์š”. ๋Œ€์ƒ repo์— app์ด ์„ค์น˜๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
2. **Add the workflow**
์•„๋ž˜ workflow ํŒŒ์ผ์„ repo์˜ `.github/workflows/opencode.yml`์— ์ถ”๊ฐ€ํ•˜์„ธ์š”. `env`์—๋Š” ํ•„์š”ํ•œ API key๋ฅผ ๋„ฃ๊ณ , `model`์€ ํ™˜๊ฒฝ์— ๋งž๊ฒŒ ์„ค์ •ํ•˜์„ธ์š”.
```yml title=".github/workflows/opencode.yml" {24,26}
name: opencode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
opencode:
if: |
contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode')
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: false
- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
model: anthropic/claude-sonnet-4-20250514
# share: true
# github_token: xxxx
```
3. **Store the API keys in secrets**
์กฐ์ง ๋˜๋Š” ํ”„๋กœ์ ํŠธ **Settings**์—์„œ ์™ผ์ชฝ์˜ **Secrets and variables**๋ฅผ ํŽผ์นœ ๋’ค **Actions**๋ฅผ ์„ ํƒํ•˜์„ธ์š”. ํ•„์š”ํ•œ API key๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
---
## ๊ตฌ์„ฑ
- `model`: OpenCode์—์„œ ์‚ฌ์šฉํ•  model์ž…๋‹ˆ๋‹ค. `provider/model` ํ˜•์‹์ด๋ฉฐ **ํ•„์ˆ˜**์ž…๋‹ˆ๋‹ค.
- `agent`: ์‚ฌ์šฉํ•  agent์ž…๋‹ˆ๋‹ค. primary agent์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฐพ์ง€ ๋ชปํ•˜๋ฉด config์˜ `default_agent`๋ฅผ ์‚ฌ์šฉํ•˜๊ณ , ๊ทธ๊ฒƒ๋„ ์—†์œผ๋ฉด `"build"`๋กœ fallbackํ•ฉ๋‹ˆ๋‹ค.
- `share`: OpenCode ์„ธ์…˜ ๊ณต์œ  ์—ฌ๋ถ€์ž…๋‹ˆ๋‹ค. public repo์—์„œ๋Š” ๊ธฐ๋ณธ๊ฐ’์ด **true**์ž…๋‹ˆ๋‹ค.
- `prompt`: ๊ธฐ๋ณธ ๋™์ž‘์„ overrideํ•˜๋Š” ์„ ํƒํ˜• custom prompt์ž…๋‹ˆ๋‹ค. OpenCode์˜ ์š”์ฒญ ์ฒ˜๋ฆฌ ๋ฐฉ์‹์„ ์กฐ์ •ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
- `token`: ๋Œ“๊ธ€ ์ƒ์„ฑ, ์ปค๋ฐ‹, PR ์ƒ์„ฑ ๊ฐ™์€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ์„ ํƒํ˜• GitHub access token์ž…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ OpenCode๋Š” OpenCode GitHub App์˜ installation access token์„ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ, ์ปค๋ฐ‹/๋Œ“๊ธ€/PR ์ž‘์„ฑ ์ฃผ์ฒด๊ฐ€ app์œผ๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
๋˜๋Š” OpenCode GitHub App์„ ์„ค์น˜ํ•˜์ง€ ์•Š๊ณ ๋„ GitHub Action runner์˜ [๊ธฐ๋ณธ ์ œ๊ณต `GITHUB_TOKEN`](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token)์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ workflow์— ํ•„์š”ํ•œ permission์„ ๋ฐ˜๋“œ์‹œ ๋ถ€์—ฌํ•˜์„ธ์š”.
```yaml
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
```
ํ•„์š”ํ•˜๋ฉด [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)(PAT)๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
---
## Supported Events
OpenCode๋Š” ์•„๋ž˜ GitHub event๋กœ ํŠธ๋ฆฌ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
| Event Type | Triggered By | Details |
| ----------------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `issue_comment` | issue ๋˜๋Š” PR ๋Œ“๊ธ€ | ๋Œ“๊ธ€์— `/opencode` ๋˜๋Š” `/oc`๋ฅผ mentionํ•˜์„ธ์š”. OpenCode๊ฐ€ ๋งฅ๋ฝ์„ ์ฝ๊ณ  branch ์ƒ์„ฑ, PR ์ƒ์„ฑ, ๋‹ต๋ณ€์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. |
| `pull_request_review_comment` | PR์˜ ํŠน์ • ์ฝ”๋“œ ์ค„ ๋Œ“๊ธ€ | ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์ค‘ `/opencode` ๋˜๋Š” `/oc`๋ฅผ mentionํ•˜์„ธ์š”. OpenCode๊ฐ€ ํŒŒ์ผ ๊ฒฝ๋กœ, ๋ผ์ธ ๋ฒˆํ˜ธ, diff ๋งฅ๋ฝ์„ ๋ฐ›์Šต๋‹ˆ๋‹ค. |
| `issues` | issue ์ƒ์„ฑ ๋˜๋Š” ์ˆ˜์ • | issue๊ฐ€ ์ƒ์„ฑ/์ˆ˜์ •๋  ๋•Œ OpenCode๋ฅผ ์ž๋™ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. `prompt` ์ž…๋ ฅ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. |
| `pull_request` | PR ์ƒ์„ฑ ๋˜๋Š” ์—…๋ฐ์ดํŠธ | PR open/synchronize/reopen ์‹œ OpenCode๋ฅผ ์ž๋™ ํŠธ๋ฆฌ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. ์ž๋™ ๋ฆฌ๋ทฐ์— ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. |
| `schedule` | cron ๊ธฐ๋ฐ˜ ์Šค์ผ€์ค„ | ์Šค์ผ€์ค„์— ๋”ฐ๋ผ OpenCode๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. `prompt` ์ž…๋ ฅ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ถœ๋ ฅ์€ ๋กœ๊ทธ์™€ PR๋กœ ๋‚จ์Šต๋‹ˆ๋‹ค(issue ๋Œ“๊ธ€ ๋Œ€์ƒ ์—†์Œ). |
| `workflow_dispatch` | GitHub UI์—์„œ ์ˆ˜๋™ ์‹คํ–‰ | Actions ํƒญ์—์„œ ํ•„์š” ์‹œ OpenCode๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. `prompt` ์ž…๋ ฅ์ด ํ•„์š”ํ•˜๋ฉฐ ์ถœ๋ ฅ์€ ๋กœ๊ทธ์™€ PR๋กœ ๋‚จ์Šต๋‹ˆ๋‹ค. |
### Schedule Example
์ž๋™ํ™” ์ž‘์—…์„ ์œ„ํ•ด ์Šค์ผ€์ค„ ๊ธฐ๋ฐ˜์œผ๋กœ OpenCode๋ฅผ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```yaml title=".github/workflows/opencode-scheduled.yml"
name: Scheduled OpenCode Task
on:
schedule:
- cron: "0 9 * * 1" # Every Monday at 9am UTC
jobs:
opencode:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Run OpenCode
uses: anomalyco/opencode/github@latest
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
model: anthropic/claude-sonnet-4-20250514
prompt: |
Review the codebase for any TODO comments and create a summary.
If you find issues worth addressing, open an issue to track them.
```
schedule event๋Š” ์ง€์‹œ๋ฅผ ์ถ”์ถœํ•  ๋Œ“๊ธ€์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— `prompt` ์ž…๋ ฅ์ด **ํ•„์ˆ˜**์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ schedule workflow๋Š” permission ์ฒดํฌ์šฉ ์‚ฌ์šฉ์ž ๋งฅ๋ฝ ์—†์ด ์‹คํ–‰๋˜๋ฏ€๋กœ, OpenCode๊ฐ€ branch๋‚˜ PR์„ ๋งŒ๋“ค๊ฒŒ ํ•˜๋ ค๋ฉด `contents: write`์™€ `pull-requests: write`๋ฅผ ๋ถ€์—ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
---
### Pull Request Example
PR์ด ์—ด๋ฆฌ๊ฑฐ๋‚˜ ์—…๋ฐ์ดํŠธ๋  ๋•Œ ์ž๋™ ๋ฆฌ๋ทฐ๋ฅผ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```yaml title=".github/workflows/opencode-review.yml"
name: opencode-review
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
review:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: read
issues: read
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- uses: anomalyco/opencode/github@latest
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
model: anthropic/claude-sonnet-4-20250514
use_github_token: true
prompt: |
Review this pull request:
- Check for code quality issues
- Look for potential bugs
- Suggest improvements
```
`pull_request` event์—์„œ `prompt`๋ฅผ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด OpenCode๋Š” pull request ๋ฆฌ๋ทฐ๋ฅผ ๊ธฐ๋ณธ ๋™์ž‘์œผ๋กœ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.
---
### Issues Triage Example
์ƒˆ๋กœ์šด issue๋ฅผ ์ž๋™์œผ๋กœ triageํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ˆ์‹œ๋Š” ์ŠคํŒธ์„ ์ค„์ด๊ธฐ ์œ„ํ•ด ๊ณ„์ • ์ƒ์„ฑ ํ›„ 30์ผ ์ด์ƒ์ธ ์‚ฌ์šฉ์ž๋งŒ ๋Œ€์ƒ์œผ๋กœ ํ•„ํ„ฐ๋งํ•ฉ๋‹ˆ๋‹ค.
```yaml title=".github/workflows/opencode-triage.yml"
name: Issue Triage
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Check account age
id: check
uses: actions/github-script@v7
with:
script: |
const user = await github.rest.users.getByUsername({
username: context.payload.issue.user.login
});
const created = new Date(user.data.created_at);
const days = (Date.now() - created) / (1000 * 60 * 60 * 24);
return days >= 30;
result-encoding: string
- uses: actions/checkout@v6
if: steps.check.outputs.result == 'true'
with:
persist-credentials: false
- uses: anomalyco/opencode/github@latest
if: steps.check.outputs.result == 'true'
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
model: anthropic/claude-sonnet-4-20250514
prompt: |
Review this issue. If there's a clear fix or relevant docs:
- Provide documentation links
- Add error handling guidance for code examples
Otherwise, do not comment.
```
`issues` event ์—ญ์‹œ ์ง€์‹œ๋ฅผ ์ถ”์ถœํ•  ๋Œ“๊ธ€์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— `prompt` ์ž…๋ ฅ์ด **ํ•„์ˆ˜**์ž…๋‹ˆ๋‹ค.
---
## Custom prompts
๊ธฐ๋ณธ prompt๋ฅผ overrideํ•ด ์›Œํฌํ”Œ๋กœ์— ๋งž๊ฒŒ OpenCode ๋™์ž‘์„ ์ปค์Šคํ„ฐ๋งˆ์ด์ฆˆํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```yaml title=".github/workflows/opencode.yml"
- uses: anomalyco/opencode/github@latest
with:
model: anthropic/claude-sonnet-4-5
prompt: |
Review this pull request:
- Check for code quality issues
- Look for potential bugs
- Suggest improvements
```
์ด ๋ฐฉ์‹์€ ํ”„๋กœ์ ํŠธ๋ณ„ ๋ฆฌ๋ทฐ ๊ธฐ์ค€, ์ฝ”๋”ฉ ํ‘œ์ค€, ์ค‘์  ์ ๊ฒ€ ํ•ญ๋ชฉ์„ ๊ฐ•์ œํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.
---
## ์˜ˆ์‹œ
์•„๋ž˜๋Š” GitHub์—์„œ OpenCode๋ฅผ ํ™œ์šฉํ•˜๋Š” ๋Œ€ํ‘œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.
- **Issue ์„ค๋ช… ์š”์ฒญ**
GitHub issue์— ์•„๋ž˜ ๋Œ“๊ธ€์„ ๋‚จ๊ธฐ์„ธ์š”.
```
/opencode explain this issue
```
OpenCode๋Š” ์ „์ฒด ์Šค๋ ˆ๋“œ์™€ ๋ชจ๋“  ๋Œ“๊ธ€์„ ์ฝ๊ณ  ๋ช…ํ™•ํ•œ ์„ค๋ช…์œผ๋กœ ๋‹ต๋ณ€ํ•ฉ๋‹ˆ๋‹ค.
- **Issue ์ˆ˜์ • ์š”์ฒญ**
GitHub issue์—์„œ ์•„๋ž˜์ฒ˜๋Ÿผ ์š”์ฒญํ•˜์„ธ์š”.
```
/opencode fix this
```
OpenCode๊ฐ€ ์ƒˆ branch๋ฅผ ๋งŒ๋“ค๊ณ  ๋ณ€๊ฒฝ์„ ๊ตฌํ˜„ํ•œ ๋’ค, ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ๋‹ด๊ธด PR์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
- **PR ๋ฆฌ๋ทฐ ์ค‘ ๋ณ€๊ฒฝ ์š”์ฒญ**
GitHub PR์— ์•„๋ž˜ ๋Œ“๊ธ€์„ ๋‚จ๊ธฐ์„ธ์š”.
```
Delete the attachment from S3 when the note is removed /oc
```
OpenCode๊ฐ€ ์š”์ฒญํ•œ ๋ณ€๊ฒฝ์„ ๊ตฌํ˜„ํ•˜๊ณ  ๊ฐ™์€ PR์— ์ปค๋ฐ‹ํ•ฉ๋‹ˆ๋‹ค.
- **ํŠน์ • ์ฝ”๋“œ ์ค„ ๋ฆฌ๋ทฐ ์š”์ฒญ**
PR์˜ "Files" ํƒญ์—์„œ ์ฝ”๋“œ ์ค„์— ์ง์ ‘ ๋Œ“๊ธ€์„ ๋‚จ๊ธฐ์„ธ์š”. OpenCode๋Š” ํŒŒ์ผ, ์ค„ ๋ฒˆํ˜ธ, diff ๋งฅ๋ฝ์„ ์ž๋™์œผ๋กœ ์ธ์‹ํ•ด ๋” ์ •ํ™•ํ•œ ์‘๋‹ต์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
```
[Comment on specific lines in Files tab]
/oc add error handling here
```
ํŠน์ • ์ค„ ๋Œ“๊ธ€์—์„œ๋Š” OpenCode๊ฐ€ ๋‹ค์Œ ์ •๋ณด๋ฅผ ํ•จ๊ป˜ ๋ฐ›์Šต๋‹ˆ๋‹ค.
- ๊ฒ€ํ†  ์ค‘์ธ ์ •ํ™•ํ•œ ํŒŒ์ผ
- ํ•ด๋‹น ์ฝ”๋“œ ์ค„
- ์ฃผ๋ณ€ diff ๋งฅ๋ฝ
- ๋ผ์ธ ๋ฒˆํ˜ธ ์ •๋ณด
๋”ฐ๋ผ์„œ ํŒŒ์ผ ๊ฒฝ๋กœ๋‚˜ ๋ผ์ธ ๋ฒˆํ˜ธ๋ฅผ ์ง์ ‘ ์ ์ง€ ์•Š์•„๋„ ๋” ์ •๋ฐ€ํ•˜๊ฒŒ ์š”์ฒญํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.