Fix: installa curl se assente, sostituisce grep -P con jq per estrazione JSON

This commit is contained in:
2026-05-30 23:28:08 +02:00
parent 4ca5287d67
commit 370c2967f0

View File

@@ -66,6 +66,17 @@ runs:
run: | run: |
set -euo pipefail 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 }}" HOST="${{ inputs.gitea-host }}"
TOKEN="${{ inputs.api-token }}" TOKEN="${{ inputs.api-token }}"
REPO="${{ inputs.repository }}" REPO="${{ inputs.repository }}"
@@ -97,14 +108,8 @@ runs:
RESPONSE=$(cat "$OUTFILE") RESPONSE=$(cat "$OUTFILE")
JSON="" # Estrai JSON dalla risposta; opencode produce JSON su una riga separata
if echo "$RESPONSE" | jq empty 2>/dev/null; then JSON=$(echo "$RESPONSE" | jq -R 'fromjson? | select(.label and .comment)' 2>/dev/null | head -1)
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
if [ -z "$JSON" ] || ! echo "$JSON" | jq empty 2>/dev/null; then if [ -z "$JSON" ] || ! echo "$JSON" | jq empty 2>/dev/null; then
echo "WARN: Impossibile estrarre JSON valido, default a richiesta" echo "WARN: Impossibile estrarre JSON valido, default a richiesta"