add optional prompt Input to Github Action (#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>
This commit is contained in:
Daniel Polito
2025-12-04 15:10:56 -03:00
committed by GitHub
parent a32cf70d7e
commit 7f86fe3f61
3 changed files with 30 additions and 0 deletions

View File

@@ -13,6 +13,10 @@ inputs:
description: "Share the opencode session (defaults to true for public repos)"
required: false
prompt:
description: "Custom prompt to override the default prompt"
required: false
runs:
using: "composite"
steps:
@@ -27,3 +31,4 @@ runs:
env:
MODEL: ${{ inputs.model }}
SHARE: ${{ inputs.share }}
PROMPT: ${{ inputs.prompt }}

View File

@@ -562,6 +562,11 @@ export const GithubRunCommand = cmd({
}
async function getUserPrompt() {
const customPrompt = process.env["PROMPT"]
if (customPrompt) {
return { userPrompt: customPrompt, promptFiles: [] }
}
const reviewContext = getReviewCommentContext()
let prompt = (() => {
const body = payload.comment.body.trim()

View File

@@ -82,6 +82,7 @@ Or you can set it up manually.
- `model`: The model to use with opencode. Takes the format of `provider/model`. This is **required**.
- `share`: Whether to share the opencode session. Defaults to **true** for public repositories.
- `prompt`: Optional custom prompt to override the default behavior. Use this to customize how opencode processes requests.
- `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.
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.
---
## Custom prompts
Override the default prompt to customize opencode's behavior for your workflow.
```yaml title=".github/workflows/opencode.yml"
- uses: sst/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
```
This is useful for enforcing specific review criteria, coding standards, or focus areas relevant to your project.
---
## Examples
Here are some examples of how you can use opencode in GitHub.