Skip to content

Instantly share code, notes, and snippets.

@brenogcota
Created April 13, 2023 19:36
Show Gist options
  • Save brenogcota/31a7f179908aaaad5a13e5b617257d93 to your computer and use it in GitHub Desktop.
Save brenogcota/31a7f179908aaaad5a13e5b617257d93 to your computer and use it in GitHub Desktop.
function pr_notify() {
url=$(echo $(gh pr view | sed '10!d' | sed 's/.*://'))
title=$(echo $(gh pr view | sed '1!d' | sed 's/.*://'))
state=$(echo $(gh pr view | sed '2!d' | sed 's/.*://'))
author=$(echo $(gh pr view | sed '3!d' | sed 's/.*://'))
data=$(echo '{
"cards": [
{
"header": {
"title": "🤖 Code Review",
},
"sections": [
{
"widgets": [
{
"keyValue": {
"topLabel": "message",
"content": "'$title'"
},
},
{
"keyValue": {
"topLabel": "author",
"content": "'$author'"
},
},
{
"keyValue": {
"topLabel": "url",
"content": "https:'$url'"
},
},
{
"keyValue": {
"topLabel": "status",
"content": "'$state'"
},
},
{
"buttons": [
{
"textButton": {
"text": "OPEN PR",
"onClick": {
"openLink": {
"url": "https:'$url'"
}
}
}
}
]
}
]
}
]
}
]
}')
curl --location --request POST '<your-webhook-url>' \
--header 'Content-Type: application/json' \
--data-raw $data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment