action.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: "opencode GitHub Action"
  2. description: "Run opencode in GitHub Actions workflows"
  3. branding:
  4. icon: "code"
  5. color: "orange"
  6. inputs:
  7. model:
  8. description: "Model to use"
  9. required: true
  10. agent:
  11. description: "Agent to use. Must be a primary agent. Falls back to default_agent from config or 'build' if not found."
  12. required: false
  13. share:
  14. description: "Share the opencode session (defaults to true for public repos)"
  15. required: false
  16. prompt:
  17. description: "Custom prompt to override the default prompt"
  18. required: false
  19. use_github_token:
  20. description: "Use GITHUB_TOKEN directly instead of OpenCode App token exchange. When true, skips OIDC and uses the GITHUB_TOKEN env var."
  21. required: false
  22. default: "false"
  23. mentions:
  24. description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'"
  25. required: false
  26. variant:
  27. description: "Model variant for provider-specific reasoning effort (e.g., high, max, minimal)"
  28. required: false
  29. oidc_base_url:
  30. description: "Base URL for OIDC token exchange API. Only required when running a custom GitHub App install. Defaults to https://api.opencode.ai"
  31. required: false
  32. runs:
  33. using: "composite"
  34. steps:
  35. - name: Get opencode version
  36. id: version
  37. shell: bash
  38. run: |
  39. VERSION=$(curl -sf https://api.github.com/repos/anomalyco/opencode/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
  40. echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
  41. - name: Cache opencode
  42. id: cache
  43. uses: actions/cache@v4
  44. with:
  45. path: ~/.opencode/bin
  46. key: opencode-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
  47. - name: Install opencode
  48. if: steps.cache.outputs.cache-hit != 'true'
  49. shell: bash
  50. run: curl -fsSL https://opencode.ai/install | bash
  51. - name: Add opencode to PATH
  52. shell: bash
  53. run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
  54. - name: Run opencode
  55. shell: bash
  56. id: run_opencode
  57. run: opencode github run
  58. env:
  59. MODEL: ${{ inputs.model }}
  60. AGENT: ${{ inputs.agent }}
  61. SHARE: ${{ inputs.share }}
  62. PROMPT: ${{ inputs.prompt }}
  63. USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
  64. MENTIONS: ${{ inputs.mentions }}
  65. VARIANT: ${{ inputs.variant }}
  66. OIDC_BASE_URL: ${{ inputs.oidc_base_url }}