chore: add notification action

[skip ci]
This commit is contained in:
Marcel S. Henselin 2026-03-25 12:14:54 +01:00
parent 064d2cf1db
commit 683bc64c12
4 changed files with 43 additions and 36 deletions

View file

@ -1,8 +1,11 @@
name: Send pull request notification to Google Chat
description: |
Sends a notification to a Google Chat room when a pull request is opened.
name: Send notification via Google Chat
description: "Sends a notification to a Google Chat room when a pull request is opened."
inputs:
webhook_url:
description: "The URL of the Google Chat webhook."
required: true
title:
description: "The title of the notification."
required: true
@ -32,28 +35,35 @@ inputs:
required: true
default: 'none'
runs:
using: "composite"
steps:
- name: Install prerequisites
shell: bash
run: apt update && apt install -y curl jq
run: |
echo "::group::apt install"
set -e
apt update
apt install -y curl jq
echo "::endgroup::"
- name: Send PR notification to Google Chat
- name: Notify via Google Chat Webhook
shell: bash
env:
WEBHOOK: ${{ inputs.webhook_url }}
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 }}" \
--arg header_title "${{ inputs.title }}" \
--arg repo "${{ github.repository || '' }}" \
--arg title "${{ inputs.event_title || 'no event title given' }}" \
--arg body "${{ inputs.event_body || 'no event body given' }}" \
--arg author "${{ inputs.event_author || 'no event author given' }}" \
--arg url "${{ inputs.event_url || 'no event url given' }}" \
'{
"header": {
"title": "${{ inputs.title }}",
"title": "$header_title",
"subtitle": "Repo: \($repo)",
"imageUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/git.png",
"imageType": "SQUARE"
@ -101,6 +111,9 @@ runs:
]
}')
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}" \
curl \
--fail-with-body \
-X POST \
-H 'Content-Type: application/json' \
"${{ inputs.webhook_url }}&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=${{ github.repository }}/pr/${{ inputs.event_number }}" \
-d "$(jq -n --argjson card "$PAYLOAD" '{ "cardsV2": [ { "cardId": "new-pr", "card": $card } ] }')"