-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (35 loc) · 1.19 KB
/
add-assignee.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
name: 'Add assignee'
on:
pull_request:
types: [opened, ready_for_review]
branches:
- 'main'
jobs:
add-assignee:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add Assignee to Pull Request
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const { data: pull } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
console.log(pull);
if (!pull.assignees || pull.assignees.length === 0) {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: [context.actor],
});
}
} catch (error) {
throw new Error(`Check this error >>> ${error.message}`);
}