terraform-provider-stackitp.../.github/actions/notify/action.yaml
Marcel S. Henselin d5b4e02437
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Failing after 1m33s
Notify on new PR / Notify via Google Chat (pull_request) Successful in 2m4s
CI Workflow / Prepare GO cache (pull_request) Successful in 4m40s
CI Workflow / Test readiness for publishing provider (pull_request) Has been skipped
CI Workflow / CI run tests (pull_request) Has been skipped
CI Workflow / CI run build and linting (pull_request) Has been skipped
CI Workflow / Code coverage report (pull_request) Has been skipped
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Failing after 1h37m59s
fix: adjust timeout
2026-03-25 13:31:03 +01:00

132 lines
3.5 KiB
YAML

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
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: event list
# shell: bash
# run: |
# cat <<'EOF'
# ${{ toJSON(github) }}
# EOF
#
# - name: print env
# shell: bash
# run: |
# env
# exit 1
- name: Install prerequisites
shell: bash
run: |
echo "::group::apt install"
set -e
apt update
apt install -y curl jq
echo "::endgroup::"
- name: Notify via Google Chat Webhook
shell: bash
env:
WEBHOOK: ${{ inputs.webhook_url }}
run: |
set -e
PAYLOAD=$(jq -n -r \
--arg header "${{ 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 || github.repositoryUrl || github.server_url }}" \
'{ "cardsV2": [ { "cardId": "notify-${{ github.run_id }}", "card": {
"header": {
"title": "\($header)",
"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' \
"${{ inputs.webhook_url }}" \
-d "${PAYLOAD}"