Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / .github / workflows / issue_labeler.yml
issue_labeler.yml35 lines · 1.9 KiBRaw
| 1 | name: "Precise Issue App Labeler" |
| 2 | on: |
| 3 | issues: |
| 4 | types: [opened] |
| 5 | |
| 6 | jobs: |
| 7 | add-labels: |
| 8 | runs-on: ubuntu-latest |
| 9 | permissions: |
| 10 | issues: write |
| 11 | steps: |
| 12 | - name: Extract App Name and Label |
| 13 | uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| 14 | with: |
| 15 | script: | |
| 16 | const body = context.payload.issue.body; |
| 17 | |
| 18 | // This regex finds the text immediately following the "### App Name" header |
| 19 | // It accounts for potential whitespace and newlines |
| 20 | const match = body.match(/### App Name\s+([\s\S]*?)(?:\n\n|###|$)/); |
| 21 | |
| 22 | if (match && match[1]) { |
| 23 | const selectedApp = match[1].trim().toLowerCase(); |
| 24 | const validApps = ['appstore', 'arrows', 'astronomy', 'auto', 'backup', 'calculator', 'calendar', 'camera', 'cast', 'chess', 'clock', 'code', 'communicate', 'contacts', 'education', 'email', 'emergency', 'euicc', 'everysync', 'files', 'findfamily', 'flashcards', 'fooddelivery', 'globalesim', 'health', 'hub', 'kart', 'keyboard', 'launcher', 'logicgate', 'logviewer', 'maps', 'measure', 'minesweeper', 'music', 'networklocation', 'nonogram', 'notes', 'office', 'openassistant', 'passwords', 'pdf', 'photos', 'pipes', 'parentalcontrols', 'screentime', 'setupwizard', 'share', 'shop', 'securemail', 'solitaire', 'speech', 'sudoku', 'taxi', 'things', 'todo', 'translate', 'travel', 'tuner', 'unblockjam', 'uniflix', 'updater', 'vpn', 'watch', 'voxels', 'weather', 'web', 'wordmaker', 'youpipe']; |
| 25 | |
| 26 | if (validApps.includes(selectedApp)) { |
| 27 | await github.rest.issues.addLabels({ |
| 28 | issue_number: context.issue.number, |
| 29 | owner: context.repo.owner, |
| 30 | repo: context.repo.repo, |
| 31 | labels: [selectedApp] |
| 32 | }); |
| 33 | console.log(`Successfully added label: ${selectedApp}`); |
| 34 | } |
| 35 | } |