| --- |
| 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 ์ค์ ๊ณผ์ ์ ์๋ดํฉ๋๋ค. |
|
|
| --- |
| |
| |
|
|
| ์ํ๋ฉด ์๋์ผ๋ก๋ ์ค์ ํ ์ ์์ต๋๋ค. |
|
|
| 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 |
| |
| |
| ``` |
|
|
| 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)๋ ์ฌ์ฉํ ์ ์์ต๋๋ค. |
|
|
| --- |
| |
| |
|
|
| 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๋ก ๋จ์ต๋๋ค. | |
|
|
| |
|
|
| ์๋ํ ์์
์ ์ํด ์ค์ผ์ค ๊ธฐ๋ฐ์ผ๋ก OpenCode๋ฅผ ์คํํ ์ ์์ต๋๋ค. |
|
|
| ```yaml title=".github/workflows/opencode-scheduled.yml" |
| name: Scheduled OpenCode Task |
|
|
| on: |
| schedule: |
| - cron: "0 9 * * 1" |
|
|
| 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`๋ฅผ ๋ถ์ฌํด์ผ ํฉ๋๋ค. |
|
|
| --- |
| |
| |
|
|
| 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 ๋ฆฌ๋ทฐ๋ฅผ ๊ธฐ๋ณธ ๋์์ผ๋ก ์ํํฉ๋๋ค. |
|
|
| --- |
| |
| |
|
|
| ์๋ก์ด 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` ์
๋ ฅ์ด **ํ์**์
๋๋ค. |
|
|
| --- |
| |
| |
|
|
| ๊ธฐ๋ณธ 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 ๋งฅ๋ฝ |
| - ๋ผ์ธ ๋ฒํธ ์ ๋ณด |
|
|
| ๋ฐ๋ผ์ ํ์ผ ๊ฒฝ๋ก๋ ๋ผ์ธ ๋ฒํธ๋ฅผ ์ง์ ์ ์ง ์์๋ ๋ ์ ๋ฐํ๊ฒ ์์ฒญํ ์ ์์ต๋๋ค. |
|
|