-
Notifications
You must be signed in to change notification settings - Fork 747
151 lines (138 loc) · 5.17 KB
/
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: "PR Assistant"
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- edited
- ready_for_review
- converted_to_draft
permissions:
pull-requests: write
contents: read
jobs:
title:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check PR title if not sematic
uses: actions/github-script@v7
id: check
with:
script: |
const script = require('./.github/scripts/check_pr_title.js')
await script({ github, context, core })
- name: Delete Comment
if: always() && steps.check.outputs.title == 'semantic'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-title"
delete: true
- name: Comment on PR
if: always() && steps.check.outputs.title == 'not-semantic'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-title"
body: |
This pull request's title is not fulfill the requirements. @${{ github.event.pull_request.user.login }} please update it 🙏.
Valid format:
```
fix(query): fix group by string bug
^ ^---------------------^
| |
| +-> Summary in present tense.
|
+-------> Type: rfc, feat, fix, refactor, ci, docs, chore
```
Valid types:
- `rfc`: this PR proposes a new RFC
- `feat`: this PR introduces a new feature to the codebase
- `fix`: this PR patches a bug in codebase
- `refactor`: this PR changes the code base without new features or bugfix
- `ci`: this PR changes build/testing/ci steps
- `docs`: this PR changes the documents or websites
- `chore`: this PR only has small changes that no need to record
cla:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check CLA if not signed
uses: actions/github-script@v7
id: check
with:
script: |
const body = context.payload.pull_request.body;
const regex = /I hereby agree to the terms of the CLA available at: https:\/\/docs.databend.com\/dev\/policies\/cla\//;
if (!regex.test(body)) {
core.setFailed('CLA is not signed');
core.setOutput('cla', 'not-signed');
} else {
core.setOutput('cla', 'signed');
}
- name: Delete Comment
if: always() && steps.check.outputs.cla == 'signed'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-cla"
delete: true
- name: Comment on PR
if: always() && steps.check.outputs.cla == 'not-signed'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-cla"
body: |
Pull request description must contain [CLA](https://docs.databend.com/dev/policies/cla/) like the following:
```
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
## Summary
Summary about this PR
- Close #issue
```
description:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check PR description checkbox
uses: actions/github-script@v7
id: check
with:
script: |
const script = require('./.github/scripts/check_pr_description.js')
await script({ context, core })
- name: Delete Comment for Tests
if: always() && steps.check.outputs.tests == 'checked'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-description-tests"
delete: true
- name: Delete Comment for Changes
if: always() && steps.check.outputs.changes == 'checked'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-description-changes"
delete: true
- name: Comment on PR for Tests
if: always() && steps.check.outputs.tests != 'checked'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-description-tests"
body: |
At least one test kind must be checked in the PR description.
@${{ github.event.pull_request.user.login }} please update it 🙏.
- name: Comment on PR for Changes
if: always() && steps.check.outputs.changes != 'checked'
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
identifier: "pr-assistant-description-changes"
body: |
At least one type of change must be checked in the PR description.
@${{ github.event.pull_request.user.login }} please update it 🙏.