Skip to content

Commit

Permalink
Improve Chat notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mhalbritter committed Mar 12, 2024
1 parent d3e96c1 commit 18473f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
30 changes: 30 additions & 0 deletions .github/actions/send-notification/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Send notification
description: Sends a Google Chat message as a notification of the job's outcome
inputs:
webhook-url:
description: 'Google Chat Webhook URL'
required: true
status:
description: 'Status of the job'
required: true
run-name:
description: 'Name of the run to include in the notification'
default: ${{ format('{0} {1}', github.ref_name, github.job) }}
runs:
using: composite
steps:
- shell: bash
run: |
echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV"
- shell: bash
if: ${{ inputs.status == 'success' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was successful"}' || true
- shell: bash
if: ${{ inputs.status == 'failure' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<users/all> *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* "}' || true
- shell: bash
if: ${{ inputs.status == 'cancelled' }}
run: |
curl -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true
10 changes: 5 additions & 5 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:
--resource-group spring-io \
--artifact-path start-site/target/start-site-exec.jar
- name: Google Chat Notification
uses: Co-qn/google-chat-notification@3691ccf4763537d6e544bc6cdcccc1965799d056
- name: Send notification
uses: ./.github/actions/send-notification
if: always()
with:
name: Build and Deploy
url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: ${{ job.status }}
if: always()
run-name: ${{ format('start.spring.io | {0}', github.ref_name) }}

0 comments on commit 18473f0

Please sign in to comment.