A public showcase repository demonstrating how to combine GitHub Cloud, GitHub Actions, and OpenCode to automatically triage issues, propose fixes, run CI, and self-heal the main branch.
| Workflow | Trigger | Outcome |
|---|---|---|
issue-triage.yml |
New or edited issue | Labels the issue (bug, enhancement, opencode-fix, etc.) |
opencode-fix.yml |
Issue labeled opencode-fix or manual dispatch |
Runs OpenCode agent, creates a branch, opens a PR |
ci.yml |
Push or pull request to main |
Runs pytest and ruff |
main-health-check.yml |
Cron every 6 hours or manual dispatch | Creates an opencode-fix issue if main CI fails |
calculator/stats.py contains a bug in median().
For an even-length list the median should be the average of the two middle values, but the current implementation returns only the upper middle value:
>>> from calculator.stats import median
>>> median([1, 2, 3, 4])
3 # BUG: expected 2.5You can reproduce the bug locally:
python demo/reproduce_issue.pygit clone https://github.com/ccyflai/opencode-demo.git
cd opencode-demopython3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txt
pip install -r requirements-dev.txtpytestYou should see:
tests/test_stats.py::test_median_even FAILED
This is expected — the OpenCode agent is meant to fix it.
Before the auto-fix workflow can run, add a secret in your GitHub repository:
- Go to Settings → Secrets and variables → Actions.
- Click New repository secret.
- Name:
OPENAI_API_KEY - Value: your API key for the configured OpenCode model.
If you use a custom endpoint (Azure OpenAI, local proxy, etc.), also add OPENAI_BASE_URL.
- Open the pre-seeded issue titled "Median calculation returns wrong result for even-length lists".
- Apply the label
opencode-fix(or let the triage workflow do it automatically). - Watch the Actions tab for the
OpenCode Auto-Fixworkflow. - When it completes, a pull request referencing
Closes #1is opened. - CI runs on the PR. If all checks pass, review and merge.
You can also trigger the fix workflow manually:
- Go to Actions → OpenCode Auto-Fix → Run workflow.
- Enter the issue number.
- Click Run workflow.
The prompt template rendered for the agent lives in .opencode/prompts/fix_issue.md.
The agent behavior rules live in .opencode/agent.yml:
- Model:
github-copilot/kimi-k2.7-code - Allowed directories: repository root
- Denied directories:
.github/,.opencode/,.git/
main-health-check.yml runs every 6 hours. If tests on main fail, it automatically creates a labeled issue (opencode-fix, ci-failure, bug), which triggers the OpenCode agent to propose a fix.
.
├── calculator/ # Demo Python package
│ ├── core.py
│ ├── stats.py # <-- contains the median bug
│ └── cli.py
├── tests/
│ ├── test_core.py
│ ├── test_stats.py # <-- exposes the median bug
│ └── test_cli.py
├── .opencode/
│ ├── agent.yml
│ └── prompts/fix_issue.md
├── .github/
│ ├── workflows/
│ │ ├── ci.yml
│ │ ├── issue-triage.yml
│ │ ├── opencode-fix.yml
│ │ └── main-health-check.yml
│ ├── scripts/
│ │ ├── prepare_fix_env.sh
│ │ └── run_opencode_fix.py
│ └── ISSUE_TEMPLATE/
│ └── bug_report.yml
├── demo/
│ └── reproduce_issue.py
├── pyproject.toml
├── requirements.txt
└── requirements-dev.txt
MIT