action.yml 1.4 KB

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