Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Verify PR Labels
name: Check Labels

on:
pull_request:
Expand All @@ -10,16 +10,75 @@ on:
permissions:
contents: read
pull-requests: read
issues: write

jobs:
label-backport-prs:
permissions:
contents: read
pull-requests: read
issues: write

name: Label Backport PRs
if: (github.repository_owner == 'PowerShell' || github.repository_owner == 'TravisEz13') && github.event.action == 'opened' && startsWith(github.event.pull_request.base.ref, 'release/v') && startsWith(github.event.pull_request.title, '[release/v')
runs-on: ubuntu-latest

steps:
- name: Label Original PRs if backport PR
continue-on-error: true
uses: actions/github-script@v7
with:
script: |
const description = github.event.pull_request.body || '';
const branch = github.event.pull_request.base.ref;
const match = description.match(/\$\$\$originalprnumber:(\d+)\$\$\$/);
if (match) {
const originalPrNumber = match[1];
console.log(`Original PR number found: ${originalPrNumber}`);

const labelName = branch.replace('release/v', 'backport-') + '.x-migrated';
console.log(`labelName: ${labelName}`);

await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: originalPrNumber,
labels: [labelName]
});
} else {
console.log("No original PR number found in the description.");
}

test-conditions:
permissions:
contents: read

name: test conditions
#if: (github.repository_owner == 'PowerShell' || github.repository_owner == 'TravisEz13')
runs-on: ubuntu-latest

steps:
- name: If Opened
continue-on-error: true
if: github.event.action == 'opened'
run: echo "yes"

- name: If ref starts with
continue-on-error: true
if: startsWith(github.event.pull_request.base.ref, 'release/v')
run: echo "yes"

- name: If title starts with
continue-on-error: true
if: startsWith(github.event.pull_request.title, '[release/v') }}
run: echo "yes"

verify-labels:
name: Verify Change Log Labels
if: github.repository_owner == 'PowerShell'
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Verify PR has label starting with 'cl-'
id: verify-labels
uses: actions/github-script@v7
Expand All @@ -28,4 +87,5 @@ jobs:
const labels = context.payload.pull_request.labels.map(label => label.name.toLowerCase());
if (!labels.some(label => label.startsWith('cl-'))) {
core.setFailed("Every PR must have at least one label starting with 'cl-'.");
}


2 changes: 1 addition & 1 deletion .github/workflows/processReminders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:

steps:
- name: check reminders and notify
uses: agrc/reminder-action@96f2ec2e1a7a53ead156504922e9bc36d64f49ee # v1.0.16
uses: agrc/reminder-action@3095f64f8f0c26c751bee802cb1008ece5953078 # v1.0.18