Skip to content

Commit e16b246

Browse files
committed
pr review
1 parent 39f18ee commit e16b246

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/pr_review.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: PR Notifications
2+
3+
on:
4+
pull_request_target:
5+
branches: [main]
6+
types: [opened, synchronize, edited, reopened, ready_for_review]
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
notify:
17+
runs-on: ubuntu-latest
18+
if: github.event.pull_request.draft != true
19+
steps:
20+
- shell: bash
21+
run: |
22+
BRANCH_URL="${{ github.event.pull_request.head.repo.html_url }}/tree/${{ github.event.pull_request.head.ref }}"
23+
24+
MM_USERS_JSON='${{ secrets.MM_USERS }}'
25+
PR_AUTHOR="${{ github.event.pull_request.user.login }}"
26+
PR_AUTHOR_MM=$(echo "$MM_USERS_JSON" | jq -r --arg author "$PR_AUTHOR" '.[$author]')
27+
MM_USERS_STRING=$(echo "$MM_USERS_JSON" | jq -r --arg exclude "$PR_AUTHOR_MM" '[.[] | select(. != $exclude and . != null and . != "")] | join(",")')
28+
29+
echo "::add-mask::$PR_AUTHOR_MM"
30+
echo "::add-mask::$MM_USERS_STRING"
31+
echo "::add-mask::$MM_USERS_JSON"
32+
33+
MESSAGE="MR [!${{ github.event.pull_request.number }}](${{ github.event.pull_request.html_url }})"
34+
MESSAGE+=" от [${{ github.event.pull_request.user.login }} ${USER_NAME}]"
35+
MESSAGE+="(${{ github.event.pull_request.user.html_url }})"
36+
MESSAGE+="(ветка: [${{ github.event.pull_request.head.ref }}](${BRANCH_URL})) готов на ревью.\n"
37+
MESSAGE+="Выбран ревьюер: ${MM_USERS_STRING}."
38+
39+
curl -X POST \
40+
-H "Content-Type: application/json" \
41+
-d "{\"text\": \"$MESSAGE\"}" \
42+
"${{ secrets.BUILD_CHAT_WEBHOOK }}"

0 commit comments

Comments
 (0)