[Playback] ASS/SRT Subtitles not rendering in Android TV And Desktop #580
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 platform | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| pull_request_target: | |
| types: [opened, edited] | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| label: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Apply platform labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const isIssue = !!context.payload.issue; | |
| const body = isIssue | |
| ? context.payload.issue.body || '' | |
| : context.payload.pull_request.body || ''; | |
| const number = isIssue | |
| ? context.payload.issue.number | |
| : context.payload.pull_request.number; | |
| const currentLabels = isIssue | |
| ? (context.payload.issue.labels || []).map(l => l.name) | |
| : (context.payload.pull_request.labels || []).map(l => l.name); | |
| const platforms = { | |
| 'Android': /Android/i, | |
| 'Android TV': /\b(Android\s*TV|Google\s*TV|Fire\s*TV)\b/i, | |
| 'iOS': /\biOS\b/i, | |
| 'macOS': /\bmacOS\b/i, | |
| 'Tizen': /\bTizen\b/i, | |
| 'Windows': /\bWindows\b/i, | |
| 'Linux': /\bLinux\b/i | |
| }; | |
| const addLabels = []; | |
| const removeLabels = []; | |
| for (const [label, regex] of Object.entries(platforms)) { | |
| const found = regex.test(body); | |
| if (found && !currentLabels.includes(label)) addLabels.push(label); | |
| if (!found && currentLabels.includes(label)) removeLabels.push(label); | |
| } | |
| if (addLabels.length) { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: number, | |
| labels: addLabels | |
| }); | |
| } | |
| for (const label of removeLabels) { | |
| try { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: number, | |
| name: label | |
| }); | |
| } catch (e) { | |
| // Label might not exist yet | |
| } | |
| } |