chore: add notification action
[skip ci]
This commit is contained in:
parent
03776cc7fd
commit
722c46b12d
3 changed files with 148 additions and 0 deletions
106
.github/actions/notify/action.yaml
vendored
Normal file
106
.github/actions/notify/action.yaml
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
name: Send pull request notification to Google Chat
|
||||
description: |
|
||||
Sends a notification to a Google Chat room when a pull request is opened.
|
||||
|
||||
inputs:
|
||||
title:
|
||||
description: "The title of the notification."
|
||||
required: true
|
||||
default: 'no title provided'
|
||||
|
||||
event_author:
|
||||
description: "The author of the event."
|
||||
required: true
|
||||
default: 'unknown'
|
||||
|
||||
event_title:
|
||||
description: "The title of the event."
|
||||
required: true
|
||||
|
||||
event_body:
|
||||
description: "The body of the event."
|
||||
required: true
|
||||
default: 'no body provided'
|
||||
|
||||
event_number:
|
||||
description: "The number of the event."
|
||||
required: true
|
||||
default: 'no number provided'
|
||||
|
||||
event_url:
|
||||
description: "The url of the event."
|
||||
required: true
|
||||
default: 'none'
|
||||
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Install prerequisites
|
||||
shell: bash
|
||||
run: apk add --no-cache curl jq
|
||||
|
||||
- name: Send PR notification to Google Chat
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
|
||||
PAYLOAD=$(jq -n \
|
||||
--arg repo "${{ github.repository }}" \
|
||||
--arg title "${{ inputs.event_title }}" \
|
||||
--arg body "${{ inputs.event_body }}" \
|
||||
--arg author "${{ inputs.event_author }}" \
|
||||
--arg url "${{ inputs.event_url }}" \
|
||||
'{
|
||||
"header": {
|
||||
"title": "${{ inputs.title }}",
|
||||
"subtitle": "Repo: \($repo)",
|
||||
"imageUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/git.png",
|
||||
"imageType": "SQUARE"
|
||||
},
|
||||
"sections": [
|
||||
{
|
||||
"header": $title,
|
||||
"collapsible": false,
|
||||
"widgets": [
|
||||
{
|
||||
"decoratedText": {
|
||||
"icon": {
|
||||
"knownIcon": "PERSON"
|
||||
},
|
||||
"text": "<b>Opened by:</b> \($author)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"textParagraph": {
|
||||
"text": $body,
|
||||
"maxLines": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgets": [
|
||||
{
|
||||
"buttonList": {
|
||||
"buttons": [
|
||||
{
|
||||
"text": "View Source Event",
|
||||
"type": "FILLED",
|
||||
"onClick": {
|
||||
"openLink": {
|
||||
"url": $url
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}')
|
||||
|
||||
curl --fail-with-body -X POST -H 'Content-Type: application/json' \
|
||||
"${{ secrets.GOOGLE_WEBHOOK_URL }}&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=${REPO}/pr/${PR_NUMBER}" \
|
||||
-d "$(jq -n --argjson card "$PAYLOAD" '{ "cardsV2": [ { "cardId": "new-pr", "card": $card } ] }')"
|
||||
Loading…
Add table
Add a link
Reference in a new issue