name: Issue Opened - Auto Label on: issues: types: [opened] jobs: auto-label: runs-on: ubuntu-latest permissions: issues: write contents: read steps: - name: Auto-label new issue uses: actions/github-script@v7 with: script: | const title = context.payload.issue.title.toLowerCase(); const body = (context.payload.issue.body || '').toLowerCase(); const text = `${title} ${body}`; const labels = []; // Type labels if (text.includes('bug') || text.includes('error') || text.includes('fix')) { labels.push('๐Ÿ› type:bug'); } else if (text.includes('feature') || text.includes('add') || text.includes('implement')) { labels.push('โœจ type:feature'); } else if (text.includes('doc') || text.includes('readme')) { labels.push('๐Ÿ“š type:docs'); } else if (text.includes('refactor') || text.includes('cleanup')) { labels.push('โ™ป๏ธ type:refactor'); } else if (text.includes('test') || text.includes('coverage')) { labels.push('๐Ÿงช type:test'); } // Priority if (text.includes('urgent') || text.includes('critical')) { labels.push('๐Ÿ“Š priority:P0-Critical'); } else if (text.includes('important') || text.includes('high')) { labels.push('โš ๏ธ priority:P1-High'); } else { labels.push('๐Ÿ“Š priority:P2-Medium'); } // State labels.push('๐Ÿ“ฅ state:pending'); // Phase labels.push('๐ŸŽฏ phase:planning'); if (labels.length > 0) { await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.issue.number, labels: labels }); }