EC-00: FIX: The Logical Error (since parameter) #1
@@ -16,8 +16,9 @@ jobs:
|
|||||||
PR_AUTHOR: ${{ gitea.actor }}
|
PR_AUTHOR: ${{ gitea.actor }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# FIX 1: Use standard short syntax to avoid upstream gitea.com connection errors
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: https://gitea.com/actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@@ -25,8 +26,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
API_URL="$API_BASE_URL/repos/$REPO/pulls/$PR_NUMBER/commits"
|
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')
|
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": .}')
|
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"
|
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"
|
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
|
- name: Auto-assign reviewers
|
||||||
run: |
|
run: |
|
||||||
REVIEWERS_JSON='{ "reviewers": ["psmattas"] }'
|
target_reviewer="psmattas"
|
||||||
|
|
||||||
if [[ -n "$REVIEWERS_JSON" ]]; then
|
# FIX 3: Check if the author is the target reviewer to avoid API error (422)
|
||||||
echo "Requesting review from: $REVIEWERS_JSON"
|
if [[ "$PR_AUTHOR" == "$target_reviewer" ]]; then
|
||||||
API_URL="$API_BASE_URL/repos/$REPO/pulls/$PR_NUMBER/requested_reviewers"
|
echo "Author is $target_reviewer. Skipping self-review request."
|
||||||
curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$REVIEWERS_JSON" "$API_URL"
|
exit 0
|
||||||
fi
|
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"
|
||||||
|
|||||||
@@ -16,15 +16,35 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Mark stale issues
|
- name: Mark stale issues
|
||||||
run: |
|
run: |
|
||||||
# Issues with no activity for 30 days
|
# Calculate timestamp for 30 days ago (seconds since epoch for comparison)
|
||||||
THIRTY_DAYS_AGO=$(date -u -d '30 days ago' '+%Y-%m-%dT%H:%M:%SZ')
|
THIRTY_DAYS_AGO_SEC=$(date -d '30 days ago' '+%s')
|
||||||
|
|
||||||
# Get all open issues updated before 30 days ago
|
# Get all open issues sorted by oldest update first
|
||||||
ISSUES=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/issues?state=open&since=$THIRTY_DAYS_AGO&sort=updated&order=asc" | jq -c '.[]')
|
# REMOVED 'since' because it filters for NEWER issues
|
||||||
|
ISSUES=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/issues?state=open&sort=updated&order=asc" | jq -c '.[]')
|
||||||
|
|
||||||
|
# Check if we have issues to process
|
||||||
|
if [ -z "$ISSUES" ]; then
|
||||||
|
echo "No open issues found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$ISSUES" | while IFS= read -r issue; do
|
echo "$ISSUES" | while IFS= read -r issue; do
|
||||||
|
# Prevent processing empty lines
|
||||||
|
if [ -z "$issue" ]; then continue; fi
|
||||||
|
|
||||||
ISSUE_NUMBER=$(echo "$issue" | jq -r '.number')
|
ISSUE_NUMBER=$(echo "$issue" | jq -r '.number')
|
||||||
UPDATED_AT=$(echo "$issue" | jq -r '.updated_at')
|
UPDATED_AT=$(echo "$issue" | jq -r '.updated_at')
|
||||||
|
|
||||||
|
# Convert issue update time to seconds
|
||||||
|
UPDATED_AT_SEC=$(date -d "$UPDATED_AT" '+%s')
|
||||||
|
|
||||||
|
# LOGIC CHECK: If the issue is newer than 30 days, stop (since list is sorted asc)
|
||||||
|
if [ "$UPDATED_AT_SEC" -gt "$THIRTY_DAYS_AGO_SEC" ]; then
|
||||||
|
# Found an issue updated recently, so we are done with the old ones
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
HAS_STALE_LABEL=$(echo "$issue" | jq -r '.labels[] | select(.name == "status: stale") | .name')
|
HAS_STALE_LABEL=$(echo "$issue" | jq -r '.labels[] | select(.name == "status: stale") | .name')
|
||||||
|
|
||||||
# Skip if already has stale label
|
# Skip if already has stale label
|
||||||
|
|||||||
Reference in New Issue
Block a user