|
1 | 1 | # Copyright (c) Microsoft Corporation.
|
2 | 2 | # Licensed under the MIT License.
|
3 | 3 |
|
4 |
| -name: Verify PR Labels |
| 4 | +name: Check Labels |
5 | 5 |
|
6 | 6 | on:
|
7 | 7 | pull_request:
|
|
10 | 10 | permissions:
|
11 | 11 | contents: read
|
12 | 12 | pull-requests: read
|
| 13 | + issues: write |
13 | 14 |
|
14 | 15 | jobs:
|
| 16 | + label-backport-prs: |
| 17 | + permissions: |
| 18 | + contents: read |
| 19 | + pull-requests: read |
| 20 | + issues: write |
| 21 | + |
| 22 | + name: Label Backport PRs |
| 23 | + if: github.repository_owner == 'PowerShell' && github.event.action == 'opened' && startsWith(github.event.pull_request.base.ref, 'release/v') && startsWith(github.event.pull_request.title, '[release/v') |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Label Original PRs if backport PR |
| 28 | + continue-on-error: true |
| 29 | + if: ${{ github.event.action == 'opened' && startsWith(github.event.pull_request.base.ref, 'release/v') && startsWith(github.event.pull_request.title, '[release/v') }} |
| 30 | + uses: actions/github-script@v7 |
| 31 | + with: |
| 32 | + script: | |
| 33 | + const description = github.event.pull_request.body || ''; |
| 34 | + const branch = github.event.pull_request.base.ref; |
| 35 | + const match = description.match(/\$\$\$originalprnumber:(\d+)\$\$\$/); |
| 36 | + if (match) { |
| 37 | + const originalPrNumber = match[1]; |
| 38 | + console.log(`Original PR number found: ${originalPrNumber}`); |
| 39 | +
|
| 40 | + const labelName = branch.replace('release/v', 'backport-') + '.x-migrated'; |
| 41 | + console.log(`labelName: ${labelName}`); |
| 42 | +
|
| 43 | + await github.issues.addLabels({ |
| 44 | + owner: context.repo.owner, |
| 45 | + repo: context.repo.repo, |
| 46 | + issue_number: originalPrNumber, |
| 47 | + labels: [labelName] |
| 48 | + }); |
| 49 | + } else { |
| 50 | + console.log("No original PR number found in the description."); |
| 51 | + } |
| 52 | +
|
15 | 53 | verify-labels:
|
| 54 | + name: Verify Change Log Labels |
16 | 55 | if: github.repository_owner == 'PowerShell'
|
17 | 56 | runs-on: ubuntu-latest
|
18 | 57 |
|
19 | 58 | steps:
|
20 |
| - - name: Check out the repository |
21 |
| - uses: actions/checkout@v4 |
22 |
| - |
23 | 59 | - name: Verify PR has label starting with 'cl-'
|
24 | 60 | id: verify-labels
|
25 | 61 | uses: actions/github-script@v7
|
|
28 | 64 | const labels = context.payload.pull_request.labels.map(label => label.name.toLowerCase());
|
29 | 65 | if (!labels.some(label => label.startsWith('cl-'))) {
|
30 | 66 | core.setFailed("Every PR must have at least one label starting with 'cl-'.");
|
31 |
| - } |
| 67 | +
|
| 68 | +
|
0 commit comments