chore: add notification action
[skip ci]
This commit is contained in:
parent
064d2cf1db
commit
683bc64c12
4 changed files with 43 additions and 36 deletions
11
.github/actions/acc_test/action.yaml
vendored
11
.github/actions/acc_test/action.yaml
vendored
|
|
@ -65,20 +65,9 @@ inputs:
|
||||||
description: "testfile to run"
|
description: "testfile to run"
|
||||||
default: ''
|
default: ''
|
||||||
|
|
||||||
|
|
||||||
#outputs:
|
|
||||||
# random-number:
|
|
||||||
# description: "Random number"
|
|
||||||
# value: ${{ steps.random-number-generator.outputs.random-number }}
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
# - name: Random Number Generator
|
|
||||||
# id: random-number-generator
|
|
||||||
# run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
|
|
||||||
# shell: bash
|
|
||||||
|
|
||||||
- name: Install needed tools
|
- name: Install needed tools
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
41
.github/actions/notify/action.yaml
vendored
41
.github/actions/notify/action.yaml
vendored
|
|
@ -1,8 +1,11 @@
|
||||||
name: Send pull request notification to Google Chat
|
name: Send notification via Google Chat
|
||||||
description: |
|
description: "Sends a notification to a Google Chat room when a pull request is opened."
|
||||||
Sends a notification to a Google Chat room when a pull request is opened.
|
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
|
webhook_url:
|
||||||
|
description: "The URL of the Google Chat webhook."
|
||||||
|
required: true
|
||||||
|
|
||||||
title:
|
title:
|
||||||
description: "The title of the notification."
|
description: "The title of the notification."
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -32,28 +35,35 @@ inputs:
|
||||||
required: true
|
required: true
|
||||||
default: 'none'
|
default: 'none'
|
||||||
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
shell: bash
|
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
|
shell: bash
|
||||||
|
env:
|
||||||
|
WEBHOOK: ${{ inputs.webhook_url }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
PAYLOAD=$(jq -n \
|
PAYLOAD=$(jq -n \
|
||||||
--arg repo "${{ github.repository }}" \
|
--arg header_title "${{ inputs.title }}" \
|
||||||
--arg title "${{ inputs.event_title }}" \
|
--arg repo "${{ github.repository || '' }}" \
|
||||||
--arg body "${{ inputs.event_body }}" \
|
--arg title "${{ inputs.event_title || 'no event title given' }}" \
|
||||||
--arg author "${{ inputs.event_author }}" \
|
--arg body "${{ inputs.event_body || 'no event body given' }}" \
|
||||||
--arg url "${{ inputs.event_url }}" \
|
--arg author "${{ inputs.event_author || 'no event author given' }}" \
|
||||||
|
--arg url "${{ inputs.event_url || 'no event url given' }}" \
|
||||||
'{
|
'{
|
||||||
"header": {
|
"header": {
|
||||||
"title": "${{ inputs.title }}",
|
"title": "$header_title",
|
||||||
"subtitle": "Repo: \($repo)",
|
"subtitle": "Repo: \($repo)",
|
||||||
"imageUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/git.png",
|
"imageUrl": "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/git.png",
|
||||||
"imageType": "SQUARE"
|
"imageType": "SQUARE"
|
||||||
|
|
@ -101,6 +111,9 @@ runs:
|
||||||
]
|
]
|
||||||
}')
|
}')
|
||||||
|
|
||||||
curl --fail-with-body -X POST -H 'Content-Type: application/json' \
|
curl \
|
||||||
"${{ secrets.GOOGLE_WEBHOOK_URL }}&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD&threadKey=${REPO}/pr/${PR_NUMBER}" \
|
--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 } ] }')"
|
-d "$(jq -n --argjson card "$PAYLOAD" '{ "cardsV2": [ { "cardId": "new-pr", "card": $card } ] }')"
|
||||||
|
|
|
||||||
21
.github/workflows/notify_pr.yaml
vendored
21
.github/workflows/notify_pr.yaml
vendored
|
|
@ -1,4 +1,4 @@
|
||||||
name: Notify Google Chat on new PR
|
name: Notify on new PR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
@ -6,15 +6,20 @@ on:
|
||||||
- opened
|
- opened
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
notify-pr-google-chat:
|
notify:
|
||||||
|
name: Notify via Google Chat
|
||||||
runs-on: stackit-docker
|
runs-on: stackit-docker
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Notify
|
- name: Notify
|
||||||
uses: ./.github/actions/notify
|
uses: ./.github/actions/notify
|
||||||
with:
|
with:
|
||||||
title: New Pull Request
|
webhook_url: ${{ secrets.GOOGLE_WEBHOOK_URL }}
|
||||||
event_title: ${{ github.event.pull_request.title }}
|
title: "New Pull Request"
|
||||||
event_author: ${{ github.event.pull_request.user.login }}
|
event_title: "${{ github.event.pull_request.title }}"
|
||||||
event_body: ${{ github.event.pull_request.body || 'No description provided.' }}
|
event_author: "${{ github.event.pull_request.user.login }}"
|
||||||
event_number: ${{ github.event.pull_request.number }}
|
event_body: "${{ github.event.pull_request.body || 'No description provided.' }}"
|
||||||
event_url: ${{ github.event.pull_request.html_url }}
|
event_number: "${{ github.event.pull_request.number }}"
|
||||||
|
event_url: "${{ github.event.pull_request.html_url }}"
|
||||||
|
|
|
||||||
6
.github/workflows/tf-acc-test.yaml
vendored
6
.github/workflows/tf-acc-test.yaml
vendored
|
|
@ -27,6 +27,9 @@ jobs:
|
||||||
name: Acceptance Tests
|
name: Acceptance Tests
|
||||||
runs-on: stackit-docker
|
runs-on: stackit-docker
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Notify
|
- name: Notify
|
||||||
uses: ./.github/actions/notify
|
uses: ./.github/actions/notify
|
||||||
with:
|
with:
|
||||||
|
|
@ -37,9 +40,6 @@ jobs:
|
||||||
event_number: ${{ github.event.id }}
|
event_number: ${{ github.event.id }}
|
||||||
event_url: "${{ github.repositoryUrl }}"
|
event_url: "${{ github.repositoryUrl }}"
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Run Test (workflow dispatch)
|
- name: Run Test (workflow dispatch)
|
||||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
uses: ./.github/actions/acc_test
|
uses: ./.github/actions/acc_test
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue