-
Notifications
You must be signed in to change notification settings - Fork 4
61 lines (55 loc) · 2.85 KB
/
Copy pathpr-description-validate.yml
File metadata and controls
61 lines (55 loc) · 2.85 KB
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
name: Validate PR description is not empty
on:
pull_request:
types: [ opened, edited, reopened, synchronize ]
permissions:
contents: read
jobs:
check-description:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Check out the repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Check PR description
id: validate_description_step
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
if (!pr || !pr.body || pr.body.trim().length === 0) {
core.setOutput('pr_description_check_passed', 'false');
}
else {
core.setOutput('pr_description_check_passed', 'true');
}
- name: Find Comment
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
- name: Update comment with validation failed statement
if: ${{ steps.validate_description_step.outputs.pr_description_check_passed == 'false' }}
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
⚠️ **Пожалуйста, добавь описание к pull request.**
Описание pull request помогает лучше понять изменения, которые вы вносите, облегчает процесс ревью и поиска причин инцидентов.
Описание должно содержать **причину** изменений: какую **проблему** решаем, **зачем** делаем изменение, а не что изменилось.
Причина может быть в описании issue или в треде, тогда достаточно указать ссылку.
* Добавь ссылку на issue или тред, в котором раскрыта причина изменения
* Если требуется, коротко опиши зачем делаешь изменение, какую проблему решаешь
Спасибо!
- name: Fail the job if description is empty
if: ${{ steps.validate_description_step.outputs.pr_description_check_passed == 'false' }}
run: |
echo "⚠️ Ошибка: Пожалуйста, добавьте описание к pull request."
exit 1