name: OpenCode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
opencode:
name: OpenCode Agent
if: |
contains(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, '/opencode')
runs-on: [self-hosted, builder]
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare OpenCode cache paths
run: |
echo "XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}" >> "$GITHUB_ENV"
echo "$HOME/.opencode/bin" >> "$GITHUB_PATH"
echo "${RUNNER_TOOL_CACHE:-$HOME/.cache}/opencode/bin" >> "$GITHUB_PATH"
- name: Install OpenCode if needed
shell: bash
run: ./.github/scripts/install-opencode.sh
- name: Run OpenCode
env:
MODEL: zhipuai-coding-plan/glm-5
USE_GITHUB_TOKEN: "true"
ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: opencode github run