@eduardo191labs/opencode-actions
v0.4.9
Published
GitHub Copilot-equivalent bot for OpenCode: PRs, reviews, issues, workflow autofix, MCP tools and comment commands.
Maintainers
Readme
opencode-actions
A GitHub bot built on OpenCode. It reviews pull requests, triages and
implements issues, fixes failing workflows, answers comment commands and exposes GitHub as
MCP tools to the agent. Reviews post inline suggestion blocks the author applies with one
click; the bot never pushes during a review.
- uses: eduardo191-star/opencode-actions@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-repo: my-org/bot-configWhat it does
| Capability | Trigger | What happens |
|---|---|---|
| PR review | pull_request opened / updated / ready | Inline comments with suggestion blocks. Never edits, approves or pushes by default. |
| Review replies | comment on a diff line | Answered in its own thread with the hunk GitHub sends. /bot fix commits to the head branch. |
| Commit review | push to a tracked branch | Reviews the change and posts it as a commit comment. |
| Issue triage | issues opened | Severity, labels, a reproduction verdict and a plan. |
| Issue answer | /bot answer | A grounded answer citing file:line. |
| Issue implementation | /bot implement | Makes the change, commits it, opens a PR. |
| Workflow autofix | workflow_run failed | Diagnoses the failure and opens a fix PR. |
| Comment commands | issue_comment | /bot review, fix, explain, test, docs, describe, triage, answer, merge, close, reopen, label, assign, implement, help. |
| PR description | /bot describe | Rewrites the body from the real diff. |
| MCP tools | while running | The agent can read PRs, comment, open issues, create branches and merge, all permission-gated. |
Configuration
The bot reads opencode-actions.yml from a configuration repository, so
permissions and models are versioned apart from the code being reviewed. Point at it with
config-repo; the file is also discovered in the checked-out repository.
Agent prompts, instructions and skills are not configuration: they belong to OpenCode.
The opencode layer is forwarded for tools, models, MCP servers and the rest, but
instructions, references and skills are dropped before the run.
The schema has two layers:
bot— GitHub behaviour: features, permissions, models, review rules, commands, secrets.opencode— forwarded to OpenCode.model,agents(without prompt text),permissions(the tool ruleset),policies,mcp,plugins,providers,commands,formatter,lsp,compaction,watcher,tool_output,media,websearch,worktree,warming,experimental, and the rest.instructions,referencesandskillsare not forwarded.
Validation: schemas/opencode-actions.schema.json.
version: 1
bot:
name: reviewer
base_branch: main
write: true
features:
pull_request_review: true
issues: true
comment_commands: true
workflow_autofix: true
# GitHub capabilities. Separate from OpenCode's tool permission ruleset.
permissions:
push_pr_branch: allow
push_default_branch: deny
manage_issues: allow
manage_pull_requests: allow
merge_pull_requests: ask
merge_protected: deny
edit_workflows: deny
run_commands: allow
read_secrets: deny
model:
id: anthropic/claude-sonnet-4
reasoning: high
tasks:
review: openai/gpt-5
autofix: anthropic/claude-sonnet-4
review:
on_findings: comment # comment | request_changes | approve | off
approve_when_clean: false
min_severity: low
max_comments: 25
suggestions: true
exclude: [dist/**, "**/*.lock", "**/*.snap"]
commands:
prefix: /bot
min_permission: write
admins: [eduardo191-star]
secrets:
env:
ANTHROPIC_API_KEY: ANTHROPIC_API_KEY
providers:
anthropic:
token_env: ANTHROPIC_API_KEY
opencode:
permissions:
- action: read
resource: "**"
effect: allow
- action: edit
resource: "docs/**"
effect: deny
mcp:
# A run always gets the reasoning and memory servers. Any other server an
# entry names is added too, except `github` and `filesystem`: either one can
# reach a branch other than the run's own, so they are dropped.
servers:
custom:
type: local
command: ["my-mcp-server"]
plugins:
- "@my-org/[email protected]"How bot.permissions maps to OpenCode
The bot translates its GitHub capabilities into OpenCode tool rules, then adds hard limits of its own:
| Bot permission | OpenCode rule |
|---|---|
| push_pr_branch: allow | edit / write / patch allowed in write modes only |
| push_pr_branch: deny | edit denied everywhere |
| edit_workflows: allow | edit on .github/workflows/** |
| run_commands: allow | shell allowed |
| read_secrets: allow | .env, .pem, .key, id_rsa readable |
A review always runs with edit, write and patch denied, even when the bot may push to
PR branches. If anything still touches the tree, the review reverts it before exiting.
Workflows
# .github/workflows/opencode-review.yml
name: opencode review
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: opencode-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: eduardo191-star/opencode-actions@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-repo: my-org/bot-config# .github/workflows/opencode-commands.yml
name: opencode commands
on:
issue_comment:
types: [created]
permissions:
contents: write
pull-requests: write
issues: write
jobs:
command:
# Only comments that actually address the bot.
if: startsWith(github.event.comment.body, '/bot') || contains(github.event.comment.body, '/bot ')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.issue.pull_request && format('refs/pull/{0}/head', github.event.issue.number) || github.event.repository.default_branch }}
fetch-depth: 0
- uses: eduardo191-star/opencode-actions@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-repo: my-org/bot-config# .github/workflows/opencode-autofix.yml
name: opencode autofix
on:
workflow_run:
workflows: [CI]
types: [completed]
permissions:
contents: write
pull-requests: write
actions: read
jobs:
autofix:
if: github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- uses: eduardo191-star/opencode-actions@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-repo: my-org/bot-configPermissions the bot needs
GITHUB_TOKEN scopes, per workflow:
| Workflow | contents | pull-requests | issues | actions |
|---|---|---|---|---|
| review | read | write | — | — |
| commands | write | write | write | — |
| issues | write | write | write | — |
| autofix | write | write | — | read |
When config-repo is private, pass config-token with a token that can read it.
Install
One repository
- uses: eduardo191-star/opencode-actions@v0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
config-repo: my-org/bot-configEvery repository of an account
The installer detects the stack in each repository (Node, Rust, Go, Python, JVM, Ruby, PHP, C/C++, .NET, Swift, Dart), skips archived, disabled and forked ones, and writes the workflows that only touch files it owns. Re-running is safe: a workflow file without the bot marker is never overwritten.
It installs itself. The Install workflow runs every six hours with --auto,
which treats a repository that already has the bot as skipped. A new repository is
picked up on the next pass, and one where the bot was removed is repaired. No person
runs anything.
With the GitHub App configured (next section) no personal token is involved. Without
it, the workflow falls back to OPENCODE_INSTALL_TOKEN, a fine-grained token with
Administration: write on the target repositories; GITHUB_TOKEN cannot install
into other repositories.
# Preview
opencode-actions-install --owner my-login --config-repo my-org/bot-config --dry-run
# Install
opencode-actions-install --owner my-login --config-repo my-org/bot-config
# One repository only
opencode-actions-install --owner my-login --repo my-project --config-repo my-org/bot-config
# An organisation
opencode-actions-install --owner org:my-org --config-repo my-org/bot-configFor a repository that already has workflows with the same names, the installer
leaves them alone and reports them. Use --exclude name (repeatable) to skip a
repository entirely.
The same thing runs from Actions, which is what the Install workflow does:
on:
workflow_dispatch:
inputs:
dry_run: { type: boolean, default: true }The workflow needs OPENCODE_APP_ID and OPENCODE_APP_PRIVATE_KEY, or
OPENCODE_INSTALL_TOKEN as a fallback.
What triggers an install
There is no schedule. Every run is caused by GitHub saying something changed:
| Event | When it happens |
|---|---|
| installation | the app was installed |
| installation_repositories | a repository was granted to the installation |
| repository | a repository was created, forked, made public, renamed or transferred |
| issues | an issue was opened, or assigned to the bot |
| issue_comment | a command or @mention was posted |
| pull_request | a pull request opened, synchronised or became ready |
| pull_request_review_comment | a comment on a diff line |
| workflow_run | a workflow finished, for the autofix |
installation and installation_repositories are lifecycle events: GitHub
delivers them to every app and rejects them inside a manifest's
default_events, so they are not listed and still arrive.
Everything else has to be subscribed, once, by hand. A GitHub App receives exactly the
events listed under Subscribe to events, with no exceptions — an app with an
empty list only ever hears about installations, check_suite and pings. The API
cannot change that list either: PATCH /app returns 404 for permissions and
events, which is why the broker and the native workflow trigger both exist. Set
them in the app's settings, Permissions & events:
https://github.com/settings/apps/opencode-actions-bot-new/permissions
Tick these six under Subscribe to events, then Save changes:
Issues Issue comment
Pull request Pull request review
Pull request review comment Workflow runPATCH /app answers 404 for events, so this is the one step the API cannot do.
Without it the bot still works through each repository's own workflow trigger,
but the Cloudflare broker never sees an event and cannot skip anything.
Forks are installed like any other repository. A fork gets pull requests and
issues, so skipping it left the bot out of exactly where a contributor works.
--exclude-forks opts out. Archived and disabled repositories are still skipped,
because nothing happens in them.
The only repository the installer skips by default is the configuration one,
which is passed to --exclude.
The webhook worker
webhook/worker.js runs on Cloudflare Workers: free tier, no dependencies, no
build step. It verifies X-Hub-Signature-256 before parsing a byte, then asks the
Install workflow to run.
Deployment is automatic. Pushing anything under webhook/ triggers
.github/workflows/webhook.yml, which tests the worker, deploys it, and checks
that a signed ping is accepted and a forged one refused. It needs two repository
secrets:
| Secret | Purpose |
|---|---|
| CLOUDFLARE_API_TOKEN | Workers Scripts: Edit |
| CLOUDFLARE_ACCOUNT_ID | the account id from the dashboard |
The worker's own secrets are set once and survive redeploys:
npx wrangler secret put WEBHOOK_SECRET --config wrangler.toml
npx wrangler secret put APP_PRIVATE_KEY --config wrangler.tomlThe app's webhook is configured from the manifest at creation, so there is
nothing to paste. scripts/wire-webhook.js repairs a mismatch between the two:
it writes the worker's secrets and PATCH /app/hook/config in one step, because
a deploy that rewrites WEBHOOK_SECRET silently breaks every delivery.
What happens after a repository is created or forked:
GitHub ── webhook ──▶ Worker ── verify HMAC ──▶ repository_dispatch(install-requested)
│
▼
Install workflow → discover → write workflowsThe worker never writes to a repository. It verifies the signature, mints an
installation token for the one repository it needs, and asks the Install
workflow to run. The installer stays the only thing that knows how to write, so
there is one implementation and not two.
Why a worker at all: Actions cannot react to "a repository exists now" in another repository, and a schedule is both slow and wasteful. The six-hour sweep stays as a safety net for what a webhook cannot see, such as a workflow deleted by hand.
The worker rejects anything whose X-Hub-Signature-256 does not match, before
parsing a byte of the body, and ignores every event except those two.
A GitHub App, so new repositories are covered on their own
The installer can act as a GitHub App instead of a personal token. That changes three things worth understanding:
| | GITHUB_TOKEN / PAT | GitHub App installation token |
|---|---|---|
| Scope | one repository (or everything a PAT can reach) | only the repositories the owner picked |
| Lifetime | the workflow run / until the PAT expires | one hour, minted per run |
| New repositories | never found | covered as soon as the installation covers the account |
| Writing workflows and secrets | needs an admin PAT | granted by the manifest, per permission |
Create the app once:
node scripts/create-app.js --owner <you> --name opencode-actions-botIt opens one page, GitHub asks you to confirm, and the app id and private key are
written as OPENCODE_APP_ID and OPENCODE_APP_PRIVATE_KEY. Then install it:
https://github.com/apps/opencode-actions-bot/installations/new
Pick the account and All repositories if new repositories should be covered automatically, or a selection if the bot should never touch the rest.
The manifest in github-app-manifest.json requests what the bot uses, nothing more:
"contents": "write", "pull_requests": "write", "issues": "write",
"workflows": "write", "secrets": "write", "administration": "write",
"checks": "write", "statuses": "write", "actions": "write",
"environments": "write", "deployments": "write", "discussions": "write",
"packages": "write", "pages": "write", "repository_projects": "write",
"security_events": "write", "metadata": "read",
"secret_scanning_alerts": "read", "vulnerability_alerts": "read"What each one buys:
| Permission | Why |
|---|---|
| contents, pull_requests, issues | commit, open and merge PRs, comment, triage |
| workflows | the installer commits the five workflow files |
| secrets | the installer writes FREEPI_JWT and the app credentials per repository |
| administration | default workflow permissions and repository settings |
| checks, statuses | report review results on the commit |
| actions | inspect failing runs for autofix |
| environments, deployments | deploy-related commands |
| discussions, packages, pages, repository_projects | the wider command surface |
| security_events, secret_scanning_alerts, vulnerability_alerts | read-only security context |
| metadata | mandatory for every app |
Changing permissions on an existing app has no API:
PATCH /appanswers404. Either edit them in the app settings, or create the app again from the updated manifest withnode scripts/create-app.js --name <name>, which is what the manifest is for.
At run time the CLI exchanges the app JWT for an installation token for the
repository in the event, sets it as GITHUB_TOKEN (so git push keeps working)
and proceeds exactly as before. If the app is not installed on a repository, the
run fails with the install URL instead of writing anything.
The Install workflow uses the same credentials: discovery lists
/installation/repositories, which includes a repository created seconds earlier,
so a new repository is picked up by the next scheduled pass with nobody doing
anything. The schedule is every six hours.
Detecting a repository
opencode-actions --mode detect # stack, workflows, install state
opencode-actions --mode plan # the workflows that would be written
opencode-actions --mode config # the compiled OpenCode configuration
opencode-actions --mode capabilities # what the bot may do on GitHubRunning with a repository's own CI
By default a commit the bot makes does not start the repository's workflows:
- every bot commit ends its subject line with
[skip ci], which GitHub honours forpushandpull_request; - a merge the bot performs carries the same marker in its commit message;
- the pull request it opens from an issue starts as a draft, because opening
a ready pull request fires
pull_requestfor every workflow the repository has.
That is what keeps a bot-driven branch out of the run history. Turn it off when the project's pipeline should check the bot's changes:
bot:
ci_on_bot_commits: true[skip ci] is GitHub's own annotation and is respected by every workflow, so
this works without editing a single file the repository owns.
/bot review on a draft still reviews it: asking is consent, and the filters
exist to spare runners, not to refuse work that was requested.
Commands
| Command | Effect |
|---|---|
| /bot review | Review the PR (comment only). |
| /bot fix <what> | Change the code and push a commit. |
| /bot explain <what> | Explain code, a diff or an error. |
| /bot test <what> | Write or run tests. |
| /bot docs | Update documentation. |
| /bot describe | Rewrite the PR description from the diff. |
| /bot triage | Classify an issue. |
| /bot answer | Answer an issue with evidence. |
| /bot implement | Implement the issue and open a PR. |
| /bot merge | Merge a PR (needs merge_pull_requests: allow). |
| /bot label +bug -docs | Add and remove labels. |
| /bot assign @user | Assign users. |
| /bot close / /bot reopen | Change issue or PR state. |
| /bot help | List commands. |
The bot answers to three shapes, and a bare mention counts:
| You write | The bot does |
|---|---|
| /bot review | runs the review command |
| @opencode review | the same |
| @opencode how does the retry loop work? | answer — a mention with no keyword is a question |
| @opencode-actions-bot fix the null check | the app slug works too, because that is what autocomplete inserts |
Names are configurable: bot.name sets the primary mention and bot.aliases
adds more, so @bot can coexist with the long slug. A mention inside an email
address or a code fence is ignored.
Commands also work in a line comment on the diff: GitHub sends the file, the line
and the hunk, so the answer is posted in that same thread. A plain comment there is
ignored unless the bot is mentioned, and /bot fix commits the change to the head
branch instead of replying with a diff.
Events
Each event is handled by its own workflow, so a repository only pays for the ones it installs.
| Event | Handler | Installed as |
|---|---|---|
| pull_request | review with inline suggestions | opencode-review.yml |
| pull_request_review_comment | in-thread reply, optional fix | opencode-comments.yml |
| issue_comment | /bot commands | opencode-commands.yml |
| issues | triage | opencode-issues.yml |
| push | commit review | opencode-commits.yml |
| workflow_run | autofix a failing run | added on demand |
GitHub Marketplace
The Marketplace checkbox has no API: GitHub only offers it in the release form,
and the listing is a property of the first release of each major line. The Marketplace
workflow therefore automates everything around it:
- verifies the public repository, the single root
action.yml, the metadata rules and the existence of the major tag; - fetches the public listing page to decide whether the action is already listed;
- opens a tracking issue with the exact click-path when it is not.
scripts/check-marketplace.js enforces the rules that only surface at publish time:
| Rule | Check |
|---|---|
| name present, ≤ 65 characters, not reserved | ✓ |
| description < 125 characters | ✓ |
| branding.icon is a Feather icon name | ✓ |
| branding.color ∈ 8 accepted values | ✓ |
| public repository, one root metadata file | ✓ |
| global name uniqueness | reported, cannot be checked offline |
To list the action: open the release for the major tag → Edit → tick Publish this Action to the GitHub Marketplace → accept the Developer Agreement if prompted → choose a category → Update release. Later releases in that major line update the listing automatically.
Release process
Nothing is built or published from a developer machine. A release is a tag:
git tag -a v0.1.2 -m "opencode-actions 0.1.2"
git push origin v0.1.2The Release workflow then:
- builds and runs the tests;
- fails if the committed JSON schema differs from the generated one;
- validates
action.ymlagainst the Marketplace rules; - publishes to npm only if the registry does not already have that version;
- creates the GitHub Release with the tarball;
- force-moves the floating major tag (
v0).
License
MIT
