From 37b33aeaca45996ec28abdae63a33d011177e758 Mon Sep 17 00:00:00 2001 From: Karan Kaneria Date: Thu, 30 Oct 2025 12:23:25 +0530 Subject: [PATCH] add workflow which will add product area as label to the issue --- .github/workflows/add-product-as-label.yml | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/add-product-as-label.yml diff --git a/.github/workflows/add-product-as-label.yml b/.github/workflows/add-product-as-label.yml new file mode 100644 index 0000000..7ca33bf --- /dev/null +++ b/.github/workflows/add-product-as-label.yml @@ -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
|\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], + });