|
| 1 | +name: Check labels |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [labeled, unlabeled] |
| 6 | + |
| 7 | +jobs: |
| 8 | + check: |
| 9 | + name: Check |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Check labels |
| 13 | + uses: actions/github-script@v7.0.1 |
| 14 | + with: |
| 15 | + script: | |
| 16 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ |
| 17 | + owner: context.repo.owner, |
| 18 | + repo: context.repo.repo, |
| 19 | + issue_number: context.issue.number |
| 20 | + }); |
| 21 | + const hasParent = labels.find(label => label.name === "has-parent"); |
| 22 | + const current = labels.find(label => label.name === "current"); |
| 23 | + if (hasParent && current) { |
| 24 | + await github.rest.issues.addLabels({ |
| 25 | + owner: context.repo.owner, |
| 26 | + repo: context.repo.repo, |
| 27 | + issue_number: context.issue.number, |
| 28 | + labels: ["wrong-base-branch"] |
| 29 | + }); |
| 30 | +
|
| 31 | + await github.rest.pulls.createReview({ |
| 32 | + pull_number: context.issue.number, |
| 33 | + owner: context.repo.owner, |
| 34 | + repo: context.repo.repo, |
| 35 | + event: "REQUEST_CHANGES", |
| 36 | + body: "As this is a feature matched with a PR in https://github.com/esphome/esphome, please target your PR to the `next` branch and rebase." |
| 37 | + }); |
| 38 | +
|
| 39 | + core.setFailed("As this is a feature matched with a PR in https://github.com/esphome/esphome, please target your PR to the 'next' branch and rebase."); |
| 40 | + } |
0 commit comments