From 370c2967f080de4f842327afb527afd40ac18562 Mon Sep 17 00:00:00 2001 From: alberto Date: Sat, 30 May 2026 23:28:08 +0200 Subject: [PATCH] Fix: installa curl se assente, sostituisce grep -P con jq per estrazione JSON --- triage-issue/action.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/triage-issue/action.yml b/triage-issue/action.yml index 7304767..a6bf667 100644 --- a/triage-issue/action.yml +++ b/triage-issue/action.yml @@ -66,6 +66,17 @@ runs: run: | set -euo pipefail + # Assicura curl (potrebbe mancare su Alpine) + if ! command -v curl &> /dev/null; then + echo "curl non trovato, tentativo di installazione..." + if command -v apt-get &> /dev/null; then + apt-get update -qq && apt-get install -y -qq curl 2>&1 || true + elif command -v apk &> /dev/null; then + apk add --no-cache curl 2>&1 || true + fi + command -v curl &> /dev/null || { echo "ERRORE: impossibile installare curl."; exit 1; } + fi + HOST="${{ inputs.gitea-host }}" TOKEN="${{ inputs.api-token }}" REPO="${{ inputs.repository }}" @@ -97,14 +108,8 @@ runs: RESPONSE=$(cat "$OUTFILE") - JSON="" - if echo "$RESPONSE" | jq empty 2>/dev/null; then - JSON="$RESPONSE" - elif JSON=$(echo "$RESPONSE" | grep -oP '\{"label":\s*"(bug|richiesta)".*?"comment":\s*".*?"\s*}' | head -1); then - : - elif JSON=$(echo "$RESPONSE" | grep -oP '\{[^}]*\}' | head -1); then - : - fi + # Estrai JSON dalla risposta; opencode produce JSON su una riga separata + JSON=$(echo "$RESPONSE" | jq -R 'fromjson? | select(.label and .comment)' 2>/dev/null | head -1) if [ -z "$JSON" ] || ! echo "$JSON" | jq empty 2>/dev/null; then echo "WARN: Impossibile estrarre JSON valido, default a richiesta"