feat: custom assigning workflow (#1028)

This commit is contained in:
Afonso Jorge Ramos 2023-12-19 15:29:50 +00:00 committed by GitHub
parent fa0e9cfea3
commit 27cafff801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
name: 'Auto Assing on Theme' name: Theme Assigner
on: on:
issues: issues:
types: [opened, edited] types: [opened, edited]
@ -9,62 +9,46 @@ jobs:
assign: assign:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: Naturalclar/issue-action@v2.0.2 - uses: actions/github-script@v7
with: with:
title-or-body: 'both' github-token: ${{ secrets.GITHUB_TOKEN }}
parameters: | script: |
[ const keywordsToAssigneesMap = {
{ BurntSienna: ["pjaspinski"],
"keywords": ["BurntSienna"], Default: ["Blacksuan19"],
"assignees": ["pjaspinski"] Dreary: ["CharlieS1103"],
}, Dribbblish: ["khanhas"],
{ Glaze: ["CharlieS1103"],
"keywords": ["Default"], Onepunch: ["okarin001"],
"assignees": ["Blacksuan19"] Sleek: ["harbassan"],
}, Turntable: ["grasonchan"],
{ Ziro: ["schnensch0"],
"keywords": ["Dreary"], Flow: ["ian-Liaozy", "Ruixi-Zhang"],
"assignees": ["CharlieS1103"] Matte: ["darkthemer"],
}, Blossom: ["Robatortas"],
{ Nightlight: ["iTenerai"],
"keywords": ["Dribbblish"], };
"assignees": ["harbassan"]
}, const issue = await github.rest.issues.get({
{ owner: context.repo.owner,
"keywords": ["Glaze"], repo: context.repo.repo,
"assignees": ["CharlieS1103"] issue_number: context.issue.number,
}, });
{
"keywords": ["Onepunch"], const title = issue.data.title;
"assignees": ["okarin001"] const body = issue.data.body;
},
{ const assignees = [];
"keywords": ["Sleek"],
"assignees": ["harbassan"] for (const [keyword, assignee] of Object.entries(keywordsToAssigneesMap)) {
}, if (title.match(new RegExp(`\\b${keyword}\\b`, "i")) || body.match(new RegExp(`\\b${keyword}\\b`, "i"))) {
{ assignees.push(...assignee);
"keywords": ["Turntable"],
"assignees": ["grasonchan"]
},
{
"keywords": ["Ziro"],
"assignees": ["schnensch0"]
},
{
"keywords": ["Flow"],
"assignees": ["ian-Liaozy", "Ruixi-Zhang"]
},
{
"keywords": ["Matte"],
"assignees": ["darkthemer"]
},
{
"keywords": ["Blossom"],
"assignees": ["Robatortas"]
},
{
"keywords": ["Nightlight"],
"assignees": ["iTenerai"]
} }
] }
github-token: '${{ secrets.GITHUB_TOKEN }}'
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: assignees,
});