Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion .github/workflows/opencode-bot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Mention bot using OpenCode
name: OpenCode bot
on:
workflow_call:
inputs:
Expand Down Expand Up @@ -99,6 +99,67 @@ on:
GH_TOKEN:
required: false
description: GitHub token for repository access
workflow_dispatch: # checkov:skip=CKV_GHA_7: Parameterized manual dispatch is an intentional trusted-operator interface.
inputs:
model:
required: true
type: string
description: Model to use with OpenCode
agent:
required: false
type: string
description: Primary agent to use
default: build
share:
required: false
type: boolean
description: Share the OpenCode session
default: false
prompt:
required: false
type: string
description: Custom prompt to override the event comment
default: ''
use-github-token:
required: false
type: boolean
description: Use GITHUB_TOKEN directly instead of OpenCode App token exchange
default: false
mentions:
required: false
type: string
description: Comma-separated list of trigger phrases
default: /opencode,/oc
variant:
required: false
type: string
description: Provider-specific model variant
default: ''
oidc-base-url:
required: false
type: string
description: Base URL for OIDC token exchange
default: https://api.opencode.ai
opencode-version:
required: false
type: string
description: OpenCode version to install
default: latest
use-bundled-toolkit:
required: false
type: boolean
description: Use the action's bundled OpenCode toolkit
default: true
timeout-minutes:
required: false
type: number
description: Maximum minutes to let OpenCode run
default: 60
runs-on:
required: false
type: string
description: Runner to use
default: ubuntu-latest
issue_comment:
types:
- created
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# opencode-action

Run an [OpenCode](https://opencode.ai/) agent from GitHub issue and pull request comments.
Run an [OpenCode](https://opencode.ai/) agent from GitHub Actions, including issue and pull request comments, pull request reviews, and manually dispatched tasks.

[![CI](https://github.com/dceoy/opencode-action/actions/workflows/ci.yml/badge.svg)](https://github.com/dceoy/opencode-action/actions/workflows/ci.yml)

Expand Down Expand Up @@ -62,12 +62,12 @@ The default setup exchanges the workflow OIDC token for an OpenCode GitHub App t

## Reusable workflows

For smaller caller workflows, this repository provides reusable workflows for the mention bot and pull request reviews:
For smaller caller workflows, this repository provides reusable workflows for OpenCode tasks and pull request reviews:

| Workflow | Purpose |
| -------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [`opencode-bot.yml`](.github/workflows/opencode-bot.yml) | Run OpenCode from trusted issue or pull request comments, or from a fixed prompt. |
| [`opencode-review.yml`](.github/workflows/opencode-review.yml) | Run the bundled `/review-pr` flow for `pull_request` events. |
| Workflow | Purpose |
| -------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`opencode-bot.yml`](.github/workflows/opencode-bot.yml) | Run OpenCode from trusted comments, manual dispatch, or a fixed prompt. |
| [`opencode-review.yml`](.github/workflows/opencode-review.yml) | Run the bundled `/review-pr` flow for `pull_request` events. |

See [Reusable workflows](docs/reusable-workflows.md) for caller examples, inputs, secrets, and permission requirements.

Expand Down Expand Up @@ -107,6 +107,8 @@ The workflow uses the repository-provided `GITHUB_TOKEN` with `contents: write`
| `timeout-minutes` | `60` | Stop OpenCode after this many minutes. |
| `oidc-base-url` | `https://api.opencode.ai` | OIDC exchange URL for a custom GitHub App installation. |

Direct `workflow_dispatch` uses the same inputs as `workflow_call`; `model` and a non-empty `prompt` are required to run the job.

When `use-github-token: true`, keep `GITHUB_TOKEN` in `env` and grant only the permissions needed for the task.

Outputs are `opencode-version` and `cache-hit`. `cache-hit` is empty on review-only runs (`prompt: /review-pr`), which always skip the cache and install fresh.
Expand Down
12 changes: 9 additions & 3 deletions docs/reusable-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

The examples below pin the reusable workflow definition to a full commit SHA. Inside the called workflow, `uses: $/.` references the action at the repository root from the same repository and running commit, so the workflow reference also pins the action implementation without a second checkout or a separate action revision input.

## Mention bot
## Manual dispatch

Use `opencode-bot.yml` for `/opencode` and `/oc` comments, or for another event with a fixed `prompt`.
`opencode-bot.yml` exposes `workflow_dispatch` with the same inputs as `workflow_call`. `model` is required, and `prompt` must be non-empty for the job to run. It can be dispatched from the Actions UI or by API clients and integrations authorized to dispatch GitHub Actions workflows.

## OpenCode bot

Use `opencode-bot.yml` for `/opencode` and `/oc` comments, direct manual dispatch, or another event with a fixed `prompt`.

<!-- prettier-ignore -->
```yaml
Expand All @@ -33,7 +37,7 @@ jobs:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
```

For comment events, the reusable workflow accepts comments only from `OWNER`, `MEMBER`, or `COLLABORATOR` author associations. On other events, set a non-empty `prompt` to run the workflow without a comment trigger.
For comment events, the reusable workflow accepts comments only from `OWNER`, `MEMBER`, or `COLLABORATOR` author associations. On non-comment events, a non-empty `prompt` is required.

## Pull request review

Expand Down Expand Up @@ -85,6 +89,8 @@ Both reusable workflows expose the action configuration plus a runner input:
| `timeout-minutes` | `60` | Maximum OpenCode runtime in minutes. |
| `runs-on` | `ubuntu-latest` | Runner label for the called job. |

Direct `workflow_dispatch` on `opencode-bot.yml` uses the same inputs.

GitHub.com's `$/path` self repository syntax resolves to the repository and commit of the workflow where it appears, including when that workflow is called from another repository. These workflows use `$/.` because the action is defined at the repository root. GitHub Enterprise Server does not support this syntax.

## Secrets
Expand Down
Loading