Skip to content
Open
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
40 changes: 40 additions & 0 deletions .github/workflows/add-product-as-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Add Product Area As Label
on:
issues:
types: [opened, edited]

permissions:
issues: write

jobs:
add-product-area-label:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const body = context.payload.issue.body || '';
const match = body.match(/###\s*Product\s*Area\s*([\s\S]*?)(?=\n###|\n##|\n<details>|\n>|\n-\s|$)/i);
if (!match) return;

const label = match[1]
.split(/\r?\n/)
.map(line => line.trim())
.find(line => line && line !== "_No response_");
if (!label) return;

await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label,
color: '0052cc'
}).catch(err => {
if (err.status !== 422) throw err; // already exists is fine
});

await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
labels: [label],
});