action.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. share:
  11. description: "Share the opencode session (defaults to true for public repos)"
  12. required: false
  13. prompt:
  14. description: "Custom prompt to override the default prompt"
  15. required: false
  16. use_github_token:
  17. description: "Use GITHUB_TOKEN directly instead of OpenCode App token exchange. When true, skips OIDC and uses the GITHUB_TOKEN env var."
  18. required: false
  19. default: "false"
  20. mentions:
  21. description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'"
  22. required: false
  23. oidc_base_url:
  24. description: "Base URL for OIDC token exchange API. Only required when running a custom GitHub App install. Defaults to https://api.opencode.ai"
  25. required: false
  26. runs:
  27. using: "composite"
  28. steps:
  29. - name: Get opencode version
  30. id: version
  31. shell: bash
  32. run: |
  33. VERSION=$(curl -sf https://api.github.com/repos/sst/opencode/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
  34. echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
  35. - name: Cache opencode
  36. id: cache
  37. uses: actions/cache@v4
  38. with:
  39. path: ~/.opencode/bin
  40. key: opencode-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
  41. - name: Install opencode
  42. if: steps.cache.outputs.cache-hit != 'true'
  43. shell: bash
  44. run: curl -fsSL https://opencode.ai/install | bash
  45. - name: Add opencode to PATH
  46. shell: bash
  47. run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
  48. - name: Run opencode
  49. shell: bash
  50. id: run_opencode
  51. run: opencode github run
  52. env:
  53. MODEL: ${{ inputs.model }}
  54. SHARE: ${{ inputs.share }}
  55. PROMPT: ${{ inputs.prompt }}
  56. USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
  57. MENTIONS: ${{ inputs.mentions }}
  58. OIDC_BASE_URL: ${{ inputs.oidc_base_url }}