diff --git a/.gitea/workflows/opencode.yml b/.gitea/workflows/opencode.yml index 109c7e2..e4abc0d 100644 --- a/.gitea/workflows/opencode.yml +++ b/.gitea/workflows/opencode.yml @@ -3,6 +3,8 @@ name: OpenCode Gitea Integration on: issue_comment: types: [created] + dispatch: + types: [workflow_dispatch] jobs: opencode-gitea: @@ -10,24 +12,40 @@ jobs: contains(github.event.comment.body, '/oc') || contains(github.event.comment.body, '/opencode') runs-on: ubuntu-latest + timeout-minutes: 20 steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 1 - persist-credentials: false - - name: Esegui OpenCode - uses: anomalyco/opencode/github@latest + - name: Install OpenCode CLI + run: | + curl -fsSL https://opencode.ai/install | bash + echo "$HOME/.opencode/bin" >> $GITHUB_PATH + + - name: Execute OpenCode (Big Pickle) env: - # Inserisci nei Secret di Gitea la chiave ottenuta dalla dashboard di OpenCode Zen + # OpenCode Zen Configuration OPENCODE_ZEN_API_KEY: ${{ secrets.OPENCODE_ZEN_API_KEY }} - # Specifichiamo l'endpoint di OpenCode Zen per l'esecuzione remota dell'agente OPENCODE_API_BASE: https://opencode.ai/zen/v1 - # Passiamo il token di Gitea per permettere l'autenticazione sulla piattaforma + OPENCODE_MODEL: opencode/big-pickle + + GITHUB_API_URL: "https://maribit.it" GITHUB_TOKEN: ${{ secrets.BOT_GITEA_TOKEN }} - with: - # Configura l'azione per invocare Big Pickle - model: opencode/big-pickle - use_github_token: true + + # Passiamo il contesto della issue corretto recuperato da Gitea + ISSUE_NUMBER: ${{ github.event.issue.number }} + COMMENT_BODY: ${{ github.event.comment.body }} + REPO_NAME: ${{ github.repository }} + run: | + # Configuriamo git nel runner per evitare blocchi sui permessi locali + git config --global user.name "OpenCode Bot" + git config --global user.email "opencode-bot@maribit.it" + + # Eseguiamo direttamente l'agente via CLI saltando i controlli bloccanti di GitHub + opencode github run \ + --token "$GITHUB_TOKEN" \ + --model "$OPENCODE_MODEL" \ + --url "$GITHUB_API_URL"