issues create fails with AUTH_REQUIRED despite gh_cli auth configured #1387
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto-label Issues | |
| on: | |
| issues: | |
| types: [opened] | |
| permissions: | |
| issues: write | |
| jobs: | |
| auto-label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Classify and label issue | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const title = context.payload.issue.title.toLowerCase(); | |
| const body = (context.payload.issue.body || '').toLowerCase(); | |
| const combined = `${title} ${body}`; | |
| const labelMap = { | |
| 'bug': ['error', 'crash', 'broken', 'fail', 'bug', 'regression', 'not working'], | |
| 'doc_gap': ['documentation', 'doc gap', 'missing doc', 'unclear', 'confusing instruction'], | |
| 'enhancement': ['feature', 'enhancement', 'improvement', 'add support', 'request'], | |
| 'question': ['how to', 'question', 'is it possible', 'can i', 'help'], | |
| 'incident': ['incident', 'outage', 'down', 'unavailable', 'data loss'], | |
| 'contract_discrepancy': ['contract', 'discrepancy', 'spec violation', 'mismatch', 'inconsistent'], | |
| }; | |
| const labelsToAdd = []; | |
| for (const [label, keywords] of Object.entries(labelMap)) { | |
| if (keywords.some(kw => combined.includes(kw))) { | |
| labelsToAdd.push(label); | |
| } | |
| } | |
| if (labelsToAdd.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.issue.number, | |
| labels: labelsToAdd, | |
| }); | |
| console.log(`Added labels: ${labelsToAdd.join(', ')}`); | |
| } else { | |
| console.log('No matching labels found for this issue.'); | |
| } |