-
-
Notifications
You must be signed in to change notification settings - Fork 33
48 lines (43 loc) · 1.58 KB
/
assign-issue-on-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Assign Issue
on:
issue_comment:
types: [created]
jobs:
assign:
runs-on: ubuntu-latest
steps:
- name: Check if mention and label exist
id: check_mentions
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const mentions = context.payload.comment.body.match(/@([a-zA-Z0-9_-]+)/g);
const label = context.payload.comment.body.match(/#([a-zA-Z0-9_-]+)/g);
return { mentions, label };
- name: Assign to mentioned users
if: ${{ steps.check_mentions.outputs.mentions != null }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const assignees = context.payload.comment.user.login;
await github.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
assignees: assignees
});
- name: Add label if mentioned
if: ${{ steps.check_mentions.outputs.label != null }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = context.payload.comment.body.match(/#([a-zA-Z0-9_-]+)/g)[0].replace('#','');
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
labels: [label]
});