Improve compatibility with Firefox #1056
Workflow file for this run
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: PR | |
| on: | |
| pull_request_target: | |
| types: [opened, reopened, edited, closed] | |
| jobs: | |
| reminder: | |
| name: Label Reminder | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Check if PR has no labels | |
| id: check | |
| uses: actions/github-script@v8 | |
| with: | |
| result-encoding: string | |
| script: | | |
| const labels = context.payload.pull_request.labels; | |
| return labels.length === 0; | |
| - name: Post comment if unlabeled | |
| if: steps.check.outputs.result == 'true' | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| message: 'To maintainers: Please add labels to this PR' | |
| Sync: | |
| if: github.event.pull_request.state == 'open' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| issues: read | |
| contents: read | |
| steps: | |
| - uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const allowed = ['bug', 'enhancement', 'meta'] | |
| const { owner, repo } = context.repo | |
| const pr = context.payload.pull_request | |
| const query = ` | |
| query($owner:String!, $repo:String!, $number:Int!) { | |
| repository(owner:$owner, name:$repo) { | |
| pullRequest(number:$number) { | |
| closingIssuesReferences(first: 10) { | |
| nodes { | |
| labels(first: 20) { | |
| nodes { name } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ` | |
| const res = await github.graphql(query, { | |
| owner, repo, number: pr.number | |
| }) | |
| const labels = new Set() | |
| for (const issue of res.repository.pullRequest.closingIssuesReferences.nodes) { | |
| for (const l of issue.labels.nodes) { | |
| if (allowed.includes(l.name)) labels.add(l.name) | |
| } | |
| } | |
| if (labels.size > 0) { | |
| await github.rest.issues.addLabels({ | |
| owner, | |
| repo, | |
| issue_number: pr.number, | |
| labels: [...labels] | |
| }) | |
| } |