Skip to content

B4 CI/CD Integration

💡 TL;DR: Connect OpenCode to your repo with GitHub Agent; trigger it with /oc or /opencode in comments.

📝 Course Notes

Key takeaways from this lesson:

B4 CI/CD Integration Notes


What You'll Learn

  • One-click GitHub Agent installation (auto-generates workflow)
  • Trigger OpenCode to execute tasks automatically in Issue/PR comments
  • Manage API Keys with GitHub Secrets (no hardcoding)

Core Approach (Best Practices)

  • Prefer GitHub Agent: Don't write glue code for "install CLI + run script + post comment" in workflow yourself.
  • Unified Trigger: Use /oc or /opencode in comments to execute on Actions runner.

Official docs: https://opencode.ai/docs/github


Follow Along

Step 1: Run the Installation Wizard

Execute in your GitHub repository root:

bash
opencode github install

The wizard will guide you through: installing GitHub App, generating workflow files, and prompting which secrets to configure.

Step 2: Commit and Push Workflow

Commit and push the generated workflow file to your repository (usually .github/workflows/opencode.yml).

Step 3: Trigger via Comment

Comment in an Issue or PR (example):

text
/oc summarize

Or:

text
/opencode summarize

Common Issues

IssueCauseSolution
Comment posted but not triggeredDidn't use /oc or /opencodeInclude the trigger phrase in your comment (e.g., /oc summarize)
Action runs but reports missing API KeyProvider's API key not configured in GitHub SecretsFollow the wizard prompts to add secrets to your repo/organization, then retry
Concerned about permissionsWorkflow permissions unclearStart with the official docs example, then tighten per your repo policy

Further Reading


Next Lesson Preview

Next lesson: Learn how to create custom development agents like Code Reviewer, Security Auditor.