diff --git a/.gitea/workflows/issue-management.yml b/.gitea/workflows/issue-management.yml index 75ce164..cccd2c3 100644 --- a/.gitea/workflows/issue-management.yml +++ b/.gitea/workflows/issue-management.yml @@ -14,12 +14,12 @@ jobs: ISSUE_NUMBER: ${{ gitea.event.issue.number }} ISSUE_AUTHOR: ${{ gitea.event.issue.user.login }} ISSUE_TITLE: ${{ gitea.event.issue.title }} + ISSUE_BODY: ${{ gitea.event.issue.body }} steps: - name: Welcome new contributors if: gitea.event.action == 'opened' run: | - # Check if this is the user's first issue AUTHOR_ISSUES=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/issues?state=all&created_by=$ISSUE_AUTHOR" | jq '. | length') if [ "$AUTHOR_ISSUES" -eq 1 ]; then @@ -29,47 +29,54 @@ jobs: fi - name: Auto-label bug reports - if: contains(gitea.event.issue.title, '[BUG]') || contains(gitea.event.issue.labels.*.name, 'bug') run: | - LABELS='{"labels": ["bug", "status: investigating"]}' - curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + if echo "$ISSUE_TITLE" | grep -q "\[BUG\]"; then + LABELS='{"labels": ["bug", "status: investigating"]}' + curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + fi - name: Auto-label feature requests - if: contains(gitea.event.issue.title, '[FEATURE]') || contains(gitea.event.issue.labels.*.name, 'feature') run: | - LABELS='{"labels": ["feature", "status: under-review"]}' - curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + if echo "$ISSUE_TITLE" | grep -q "\[FEATURE\]"; then + LABELS='{"labels": ["feature", "status: under-review"]}' + curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + fi - name: Auto-label support requests - if: contains(gitea.event.issue.title, '[SUPPORT]') || contains(gitea.event.issue.labels.*.name, 'question') run: | - LABELS='{"labels": ["question", "status: needs-response"]}' - curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + if echo "$ISSUE_TITLE" | grep -q "\[SUPPORT\]"; then + LABELS='{"labels": ["question", "status: needs-response"]}' + curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + fi - name: Auto-label documentation issues - if: contains(gitea.event.issue.title, '[DOCS]') || contains(gitea.event.issue.labels.*.name, 'documentation') run: | - LABELS='{"labels": ["documentation", "status: under-review"]}' - curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + if echo "$ISSUE_TITLE" | grep -q "\[DOCS\]"; then + LABELS='{"labels": ["documentation", "status: under-review"]}' + curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$LABELS" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels" + fi - name: Assign to team for critical bugs - if: contains(gitea.event.issue.labels.*.name, 'priority: critical') run: | - ASSIGNEES='{"assignees": ["psmattas"]}' - curl -s -f -X PATCH -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$ASSIGNEES" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER" + LABELS=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels") + HAS_CRITICAL=$(echo "$LABELS" | jq -r '.[] | select(.name == "priority: critical") | .name') - URGENT_MSG="🚨 **Critical Issue Detected**\n\nThis issue has been marked as critical and assigned to @psmattas for immediate attention.\n\nExpected response time: **4 hours**" - COMMENT_JSON=$(jq -n --arg body "$URGENT_MSG" '{"body": $body}') - curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$COMMENT_JSON" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/comments" + if [ -n "$HAS_CRITICAL" ]; then + ASSIGNEES='{"assignees": ["psmattas"]}' + curl -s -f -X PATCH -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$ASSIGNEES" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER" + + URGENT_MSG="🚨 **Critical Issue Detected**\n\nThis issue has been marked as critical and assigned to @psmattas for immediate attention.\n\nExpected response time: **4 hours**" + COMMENT_JSON=$(jq -n --arg body "$URGENT_MSG" '{"body": $body}') + curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$COMMENT_JSON" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/comments" + fi - name: Request more info for incomplete issues if: gitea.event.action == 'opened' run: | - # Check if it's a bug report missing steps to reproduce - IS_BUG=$(echo '${{ toJSON(gitea.event.issue.labels) }}' | jq -r '.[] | select(.name == "bug") | .name') - HAS_STEPS=$(echo '${{ gitea.event.issue.body }}' | grep -q "Steps to Reproduce" && echo "yes" || echo "no") + LABELS=$(curl -s -H "Authorization: token $API_TOKEN" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/labels") + IS_BUG=$(echo "$LABELS" | jq -r '.[] | select(.name == "bug") | .name') - if [ -n "$IS_BUG" ] && [ "$HAS_STEPS" = "no" ]; then + if [ -n "$IS_BUG" ] && ! echo "$ISSUE_BODY" | grep -q "Steps to Reproduce"; then INFO_MSG="Hi @$ISSUE_AUTHOR! 👋\n\nTo help us investigate this bug, could you please provide:\n\n1. **Steps to reproduce** the issue\n2. **Expected behavior** vs **actual behavior**\n3. Your **subscription tier**\n4. **Event IDs** or **timestamps** (if applicable)\n\nThis will help us resolve the issue faster. Thanks!" COMMENT_JSON=$(jq -n --arg body "$INFO_MSG" '{"body": $body}') curl -s -f -X POST -H "Authorization: token $API_TOKEN" -H "Content-Type: application/json" -d "$COMMENT_JSON" "$API_BASE_URL/repos/$REPO/issues/$ISSUE_NUMBER/comments"