chore: add notification action

[skip ci]
This commit is contained in:
Marcel S. Henselin 2026-03-25 11:09:32 +01:00
parent 03776cc7fd
commit 722c46b12d
3 changed files with 148 additions and 0 deletions

106
.github/actions/notify/action.yaml vendored Normal file
View 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 } ] }')"

22
.github/workflows/notify_pr.yaml vendored Normal file
View file

@ -0,0 +1,22 @@
name: Notify Google Chat on new PR
on:
pull_request:
types:
- opened
jobs:
notify-pr-google-chat:
runs-on: docker
container:
image: alpine:latest
steps:
- name: Notify
uses: ./.github/actions/notify
with:
title: New Pull Request
event_title: ${{ github.event.pull_request.title }}
event_author: ${{ github.event.pull_request.user.login }}
event_body: ${{ github.event.pull_request.body || 'No description provided.' }}
event_number: ${{ github.event.pull_request.number }}
event_url: ${{ github.event.pull_request.html_url }}

View file

@ -27,6 +27,16 @@ jobs:
name: Acceptance Tests
runs-on: stackit-docker
steps:
- name: Notify
uses: ./.github/actions/notify
with:
title: Terraform Acceptance Tests started
event_title: ${{ github.event.type }}
event_author: ${{ github.event.actor.login }}
event_body: 'No event body.'
event_number: ${{ github.event.id }}
event_url: "${{ github.repositoryUrl }}"
- name: Checkout
uses: actions/checkout@v6
@ -59,3 +69,13 @@ jobs:
tf_acc_kek_key_ring_id: ${{ vars.TF_ACC_KEK_KEY_RING_ID }}
tf_acc_kek_key_version: ${{ vars.TF_ACC_KEK_KEY_VERSION }}
tf_acc_kek_service_account: ${{ vars.TF_ACC_KEK_SERVICE_ACCOUNT }}
- name: Notify
uses: ./.github/actions/notify
with:
title: Terraform Acceptance Tests finished
event_title: ${{ github.event.type }}
event_author: ${{ github.event.actor.login }}
event_body: 'No event body.'
event_number: ${{ github.event.id }}
event_url: "${{ github.repositoryUrl }}"