EC-00: FIX: The Logical Error (since parameter) #1

Closed
Puranjay Savar Mattas wants to merge 2 commits from EC-00-Action-Bugs into main
Showing only changes of commit 4aca6997ff - Show all commits

View File

@@ -16,8 +16,9 @@ jobs:
PR_AUTHOR: ${{ gitea.actor }}
steps:
# FIX 1: Use standard short syntax to avoid upstream gitea.com connection errors
- name: Check out repository
uses: https://gitea.com/actions/checkout@v4
uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -25,8 +26,15 @@ jobs:
run: |
API_URL="$API_BASE_URL/repos/$REPO/pulls/$PR_NUMBER/commits"
MESSAGES=$(curl -s -H "Authorization: token $API_TOKEN" "$API_URL" | jq -r '.[].commit.message')
UNIQUE_TYPES=$(echo "$MESSAGES" | grep -oP '^EC-\d+: \K(FEAT|FIX|DOCS|STYLE|REFACTOR|PERF|TEST|CHORE)' | sort -u)
if [[ -z "$UNIQUE_TYPES" ]]; then exit 0; fi
# FIX 2: Added '|| true' to prevent failure if no matches are found (grep returns 1 on no match)
UNIQUE_TYPES=$(echo "$MESSAGES" | grep -oP '^EC-\d+: \K(FEAT|FIX|DOCS|STYLE|REFACTOR|PERF|TEST|CHORE)' | sort -u || true)
if [[ -z "$UNIQUE_TYPES" ]]; then
echo "No semantic commit types found."
exit 0
fi
LABELS_JSON=$(echo "$UNIQUE_TYPES" | jq -R '("type: " + (. | ascii_downcase))' | jq -s '{"labels": .}')
ISSUES_API_URL="$API_BASE_URL/repos/$REPO/issues/$PR_NUMBER/labels"
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS_JSON" "$ISSUES_API_URL"
@@ -66,10 +74,15 @@ jobs:
- name: Auto-assign reviewers
run: |
REVIEWERS_JSON='{ "reviewers": ["psmattas"] }'
target_reviewer="psmattas"
if [[ -n "$REVIEWERS_JSON" ]]; then
echo "Requesting review from: $REVIEWERS_JSON"
# FIX 3: Check if the author is the target reviewer to avoid API error (422)
if [[ "$PR_AUTHOR" == "$target_reviewer" ]]; then
echo "Author is $target_reviewer. Skipping self-review request."
exit 0
fi
REVIEWERS_JSON="{\"reviewers\": [\"$target_reviewer\"]}"
echo "Requesting review from: $target_reviewer"
API_URL="$API_BASE_URL/repos/$REPO/pulls/$PR_NUMBER/requested_reviewers"
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$REVIEWERS_JSON" "$API_URL"
fi