-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.41 KB
/
Copy pathpr-webhook.yml
File metadata and controls
46 lines (39 loc) · 1.41 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
name: NEW PR Webhook Notifier
on:
pull_request:
types: [opened]
jobs:
send-webhook:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get PR diff
run: |
curl -H "Accept: application/vnd.github.v3.diff" \
"${{ github.event.pull_request.url }}" > pr.diff
- name: Send webhook with PR info and diff
env:
WEBHOOK_URL: https://pr-watcher.automations-3d6.workers.dev
run: |
PR_INFO=$(jq -n \
--arg title "${{ github.event.pull_request.title }}" \
--arg body "${{ github.event.pull_request.body }}" \
--arg url "${{ github.event.pull_request.html_url }}" \
--arg user "${{ github.event.pull_request.user.login }}" \
--arg created_at "${{ github.event.pull_request.created_at }}" \
--arg branch "${{ github.event.pull_request.head.ref }}" \
--arg base "${{ github.event.pull_request.base.ref }}" \
'{
title: $title,
body: $body,
url: $url,
user: $user,
created_at: $created_at,
branch: $branch,
base: $base
}')
DIFF=$(cat pr.diff | jq -Rs .)
curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "{\"pr_info\": $PR_INFO, \"diff\": $DIFF}"