action.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. runs:
  24. using: "composite"
  25. steps:
  26. - name: Get opencode version
  27. id: version
  28. shell: bash
  29. run: |
  30. VERSION=$(curl -sf https://api.github.com/repos/sst/opencode/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
  31. echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
  32. - name: Cache opencode
  33. id: cache
  34. uses: actions/cache@v4
  35. with:
  36. path: ~/.opencode/bin
  37. key: opencode-${{ runner.os }}-${{ runner.arch }}-${{ steps.version.outputs.version }}
  38. - name: Install opencode
  39. if: steps.cache.outputs.cache-hit != 'true'
  40. shell: bash
  41. run: curl -fsSL https://opencode.ai/install | bash
  42. - name: Add opencode to PATH
  43. shell: bash
  44. run: echo "$HOME/.opencode/bin" >> $GITHUB_PATH
  45. - name: Run opencode
  46. shell: bash
  47. id: run_opencode
  48. run: opencode github run
  49. env:
  50. MODEL: ${{ inputs.model }}
  51. SHARE: ${{ inputs.share }}
  52. PROMPT: ${{ inputs.prompt }}
  53. USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
  54. MENTIONS: ${{ inputs.mentions }}