Skip to content

Commit 7f86fe3

Browse files
dbpolitoactions-userrekram1-nodeopencode-agent[bot]
authored
add optional prompt Input to Github Action (anomalyco#4828)
Co-authored-by: Github Action <action@github.com> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
1 parent a32cf70 commit 7f86fe3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

github/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: "Share the opencode session (defaults to true for public repos)"
1414
required: false
1515

16+
prompt:
17+
description: "Custom prompt to override the default prompt"
18+
required: false
19+
1620
runs:
1721
using: "composite"
1822
steps:
@@ -27,3 +31,4 @@ runs:
2731
env:
2832
MODEL: ${{ inputs.model }}
2933
SHARE: ${{ inputs.share }}
34+
PROMPT: ${{ inputs.prompt }}

packages/opencode/src/cli/cmd/github.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ export const GithubRunCommand = cmd({
562562
}
563563

564564
async function getUserPrompt() {
565+
const customPrompt = process.env["PROMPT"]
566+
if (customPrompt) {
567+
return { userPrompt: customPrompt, promptFiles: [] }
568+
}
569+
565570
const reviewContext = getReviewCommentContext()
566571
let prompt = (() => {
567572
const body = payload.comment.body.trim()

packages/web/src/content/docs/github.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Or you can set it up manually.
8282

8383
- `model`: The model to use with opencode. Takes the format of `provider/model`. This is **required**.
8484
- `share`: Whether to share the opencode session. Defaults to **true** for public repositories.
85+
- `prompt`: Optional custom prompt to override the default behavior. Use this to customize how opencode processes requests.
8586
- `token`: Optional GitHub access token for performing operations such as creating comments, committing changes, and opening pull requests. By default, opencode uses the installation access token from the opencode GitHub App, so commits, comments, and pull requests appear as coming from the app.
8687

8788
Alternatively, you can use the GitHub Action runner's [built-in `GITHUB_TOKEN`](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token) without installing the opencode GitHub App. Just make sure to grant the required permissions in your workflow:
@@ -98,6 +99,25 @@ Or you can set it up manually.
9899
99100
---
100101
102+
## Custom prompts
103+
104+
Override the default prompt to customize opencode's behavior for your workflow.
105+
106+
```yaml title=".github/workflows/opencode.yml"
107+
- uses: sst/opencode/github@latest
108+
with:
109+
model: anthropic/claude-sonnet-4-5
110+
prompt: |
111+
Review this pull request:
112+
- Check for code quality issues
113+
- Look for potential bugs
114+
- Suggest improvements
115+
```
116+
117+
This is useful for enforcing specific review criteria, coding standards, or focus areas relevant to your project.
118+
119+
---
120+
101121
## Examples
102122
103123
Here are some examples of how you can use opencode in GitHub.

0 commit comments

Comments
 (0)