-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (76 loc) · 2.67 KB
/
configure-pr.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Configure PR When PR Opened
on:
pull_request:
types:
- opened
permissions:
contents: read
jobs:
check-title:
name: Check PR Title
runs-on: ubuntu-latest
steps:
- name: Check PR title
uses: deepakputhraya/action-pr-title@master
with:
regex: '((Be|Fe|Devops|Be,fe|Fe,be)\/(feature|bugfix|hotfix|refactor)(,(feature|bugfix|hotfix|refactor))*\/#[\d]+( #[\d]+)*.+|release v[\d]+\.[\d]+\.[\d]+)'
github_token: ${{ secrets.ADD_TO_PROJECT_PAT }}
set-label:
name: Set Labels to PR
needs: check-title
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: TimonVS/pr-labeler-action@v5
with:
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
configuration-path: .github/pr-labels.yml
set-issue:
name: Set Issue to PR
needs: check-title
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
if: github.event.pull_request.base.ref != 'release'
with:
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
script: |
const prTitle = context.payload.pull_request.title;
const issueNumbers = prTitle.match(/#(\d+)/g);
const prefix = issueNumbers ? issueNumbers.reduce((acc, curr) => `${acc}🔮 resolved ${curr}\n`, "") : '';
const body = context.payload.pull_request.body.replace(/(🔮 resolved #\d+)+/g, '');
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.number,
body: `${prefix}${body}`,
});
issueNumbers?.forEach((num) => {
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: num.replace('#', ''),
state: 'open',
});
});
set-assignee:
name: Set Assignee to PR
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
if: github.event.pull_request.base.ref != 'release'
with:
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
script: |
const sender = context.payload.sender.login;
const assignees = context.payload.pull_request.assignees;
const newAssignees = assignees ?? [];
newAssignees.push(sender);
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.number,
assignees: newAssignees,
});