action.yml 1.6 KB

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