terraform-provider-stackitp.../.github/actions/notify/action.yaml
Marcel S. Henselin 722c46b12d chore: add notification action
[skip ci]
2026-03-25 11:09:32 +01:00

106 lines
3 KiB
YAML

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 } ] }')"