[FEATURE] add designing to the home page #1
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 and PRs | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| pull_request: | |
| types: [opened, edited] | |
| jobs: | |
| auto-label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Auto-label based on title and body | |
| uses: actions/github-script@v1 | |
| with: | |
| script: | | |
| const issue = context.issue; | |
| const title = context.payload.issue?.title || context.payload.pull_request?.title || ''; | |
| const body = context.payload.issue?.body || context.payload.pull_request?.body || ''; | |
| const isPR = context.eventName === 'pull_request'; | |
| // Define label mappings | |
| const labelMappings = { | |
| 'bug': ['bug', 'error', 'crash', 'broken', 'fix', 'issue'], | |
| 'enhancement': ['feature', 'enhancement', 'improvement', 'new', 'add'], | |
| 'documentation': ['docs', 'documentation', 'readme', 'guide', 'tutorial'], | |
| 'help wanted': ['help', 'question', 'support', 'assistance'], | |
| 'good first issue': ['beginner', 'easy', 'first', 'starter', 'simple'], | |
| 'priority: high': ['urgent', 'critical', 'important', 'high priority'], | |
| 'priority: low': ['low priority', 'minor', 'nice to have'], | |
| 'frontend': ['react', 'ui', 'ux', 'frontend', 'client', 'browser'], | |
| 'backend': ['node', 'server', 'api', 'backend', 'database'], | |
| 'testing': ['test', 'testing', 'spec', 'unit test', 'integration'] | |
| }; | |
| // Determine labels to add | |
| const labelsToAdd = []; | |
| const content = (title + ' ' + body).toLowerCase(); | |
| for (const [label, keywords] of Object.entries(labelMappings)) { | |
| if (keywords.some(keyword => content.includes(keyword))) { | |
| labelsToAdd.push(label); | |
| } | |
| } | |
| // Add type-specific labels | |
| if (isPR) { | |
| labelsToAdd.push('pull request'); | |
| } else { | |
| labelsToAdd.push('issue'); | |
| } | |
| // Add auto-assigned label if it's an issue | |
| if (!isPR) { | |
| labelsToAdd.push('auto-assigned'); | |
| } | |
| // Remove duplicates | |
| const uniqueLabels = [...new Set(labelsToAdd)]; | |
| if (uniqueLabels.length > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner: issue.owner, | |
| repo: issue.repo, | |
| issue_number: issue.number, | |
| labels: uniqueLabels | |
| }); | |
| console.log(`Added labels: ${uniqueLabels.join(', ')}`); | |
| } |