action.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. oidc_base_url:
  27. description: "Base URL for OIDC token exchange API. Only required when running a custom GitHub App install. Defaults to https://api.opencode.ai"
  28. required: false
  29. runs:
  30. using: "composite"
  31. steps:
  32. - name: Get opencode version
  33. id: version
  34. shell: bash
  35. run: |
  36. VERSION=$(curl -sf https://api.github.com/repos/anomalyco/opencode/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
  37. echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
  38. - name: Cache opencode
  39. id: cache
  40. uses: actions/cache@v4
  41. with:
  42. path: ~/.opencode/bin
  43. key: opencode-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
  44. - name: Install opencode
  45. if: steps.cache.outputs.cache-hit != 'true'
  46. shell: bash
  47. run: curl -fsSL https://opencode.ai/install | bash
  48. - name: Add opencode to PATH
  49. shell: bash
  50. run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
  51. - name: Run opencode
  52. shell: bash
  53. id: run_opencode
  54. run: opencode github run
  55. env:
  56. MODEL: ${{ inputs.model }}
  57. AGENT: ${{ inputs.agent }}
  58. SHARE: ${{ inputs.share }}
  59. PROMPT: ${{ inputs.prompt }}
  60. USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
  61. MENTIONS: ${{ inputs.mentions }}
  62. OIDC_BASE_URL: ${{ inputs.oidc_base_url }}