Fix set -e crash when no PR is found for the triggering commit
CI / build-and-scan (push) Canceled after 11s

This commit is contained in:
Djeex
2026-08-22 16:01:08 +02:00
parent 0b0c14f4f7
commit 6f44532287
+6 -4
View File
@@ -122,7 +122,7 @@ jobs:
docker push "$IMAGE:$VERSION"
TRIGGER_MSG=$(git log -1 --format=%s "${{ github.sha }}")
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#')
PR_NUM=$(echo "$TRIGGER_MSG" | grep -oE '#[0-9]+' | head -1 | tr -d '#' || true)
CATEGORY="🔧 Maintenance"
CHANGE_TITLE="$TRIGGER_MSG"
@@ -130,10 +130,12 @@ jobs:
if [ -n "$PR_NUM" ]; then
PR_JSON=$(curl -s -H "Authorization: token ${{ secrets.CI_PUSH_TOKEN }}" \
"https://git.djeex.fr/api/v1/repos/Djeex/adguard-cidre/pulls/$PR_NUM")
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty')
LABELS=$(echo "$PR_JSON" | jq -r '.labels[].name' 2>/dev/null)
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty' 2>/dev/null || true)
LABELS=$(echo "$PR_JSON" | jq -r '.labels[]?.name' 2>/dev/null || true)
[ -n "$PR_TITLE" ] && CHANGE_TITLE="$PR_TITLE"
if [ -n "$PR_TITLE" ]; then
CHANGE_TITLE="$PR_TITLE"
fi
if echo "$LABELS" | grep -qx 'bug'; then
CATEGORY="⚠️ Hotfix"