diff --git a/.github/workflows/issue-assistant.yml b/.github/workflows/issue-assistant.yml index 0e2e6920..6f703394 100644 --- a/.github/workflows/issue-assistant.yml +++ b/.github/workflows/issue-assistant.yml @@ -556,6 +556,27 @@ Keep responses concise (50-150 words). No signatures.`; }; const state = stateMap[outcome] || 'gathering'; + // Try to add labels before posting comment + let labelAdditionFailed = false; + const labelsToAdd = []; + if (outcome === 'escalated') { + labelsToAdd.push('needs-maintainer'); + } + if (labelsToAdd.length > 0) { + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: labelsToAdd + }); + console.log('Successfully added labels:', labelsToAdd.join(', ')); + } catch (e) { + console.log('Could not add labels:', e.message); + labelAdditionFailed = true; + } + } + // Build comment with hidden state marker let comment = `\n`; comment += response + '\n\n'; @@ -570,6 +591,9 @@ Keep responses concise (50-150 words). No signatures.`; comment += `
🏷️ Escalated to maintainers\n\n`; comment += `A maintainer will review this issue. `; comment += `No further bot responses will be sent.\n`; + if (labelAdditionFailed) { + comment += `\n⚠️ **Note:** Unable to automatically add the \`needs-maintainer\` label. Please add it manually to ensure proper triage.\n`; + } } else { comment += `
💬 Gathering info\n\n`; comment += `Reply with the requested information and I'll try to help further.\n`; @@ -585,24 +609,6 @@ Keep responses concise (50-150 words). No signatures.`; body: comment }); - // Add/update labels based on outcome - const labelsToAdd = []; - if (outcome === 'escalated') { - labelsToAdd.push('needs-maintainer'); - } - if (labelsToAdd.length > 0) { - try { - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: labelsToAdd - }); - } catch (e) { - console.log('Could not add labels:', e.message); - } - } - console.log(`Posted response with outcome: ${outcome}, state: ${state}`); - name: Post Fallback Comment