forked from AnandChowdhary/readme-repos-list
-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (73 loc) · 2.69 KB
/
pull-request.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
name: PR Generator CI
on:
push:
branches-ignore:
- master
- production
jobs:
auto-pull-request:
name: PullRequestAction
runs-on: ubuntu-latest
steps:
- name: Generate branch name
uses: actions/[email protected]
id: set-branch-name
with:
script: |
const capitalize = (name) => name.charAt(0).toUpperCase() + name.slice(1);
const emoji = context.payload.ref.startsWith("refs/heads/feature")
? "✨ "
: context.payload.ref.startsWith("refs/heads/hotfix")
? "🚑 "
: context.payload.ref.startsWith("refs/heads/bug")
? "🐛 "
: "";
return `${emoji}${capitalize(
context.payload.ref
.replace("refs/heads/", "")
.replace(/-/g, " ")
.replace("feature ", "")
.replace("bug ", "")
.replace("hotfix ", "")
)}`;
result-encoding: string
- name: Set branch name
run: echo "PULL_REQUEST_TITLE=${{steps.set-branch-name.outputs.result}}" >> $GITHUB_ENV
- name: Generate PR body
uses: actions/[email protected]
id: set-pr-body
with:
script: |
return `I'm opening this pull request for this branch, pushed by @${
context.payload.head_commit.author.username
} with ${context.payload.commits.length} commit${
context.payload.commits.length === 1 ? "" : "s"
}.`;
result-encoding: string
- name: Set PR body
run: echo "PULL_REQUEST_BODY=${{steps.set-pr-body.outputs.result}}" >> $GITHUB_ENV
- name: Generate PR draft
uses: actions/[email protected]
id: set-pr-draft
with:
script: |
return !context.payload.ref.startsWith("refs/heads/hotfix");
- name: Set PR draft
run: echo "PULL_REQUEST_DRAFT=${{steps.set-pr-draft.outputs.result}}" >> $GITHUB_ENV
- name: Determine whether to merge
uses: actions/[email protected]
id: should-pr
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
return
context.payload.ref.startsWith("refs/heads/feature") ||
context.payload.ref.startsWith("refs/heads/hotfix") ||
context.payload.ref.startsWith("refs/heads/bug");
- name: pull-request-action
uses: vsoch/[email protected]
if: always() && steps.should-pr.outputs.result
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: "master"
PULL_REQUEST_REVIEWERS: "AnandChowdhary"