Send notification when a test passes unexpectedly

See gh-210
This commit is contained in:
Andy Wilkinson
2024-05-13 10:39:31 +01:00
parent 8a0aa601a2
commit e36fa988df
3 changed files with 12 additions and 7 deletions

View File

@@ -16,9 +16,12 @@ inputs:
webhook-url:
description: 'Google Chat Webhook URL'
required: true
outcome-description:
required: false
default: 'failed'
runs:
using: composite
steps:
- shell: bash
run: |
curl -s -o /dev/null -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d "{ text: \"${{ inputs.owner-ids }} ${{ inputs.task }} <${{ inputs.failure-url }}|failed> on ${{ inputs.branch }} \"}" || true
curl -s -o /dev/null -X POST '${{ inputs.webhook-url }}' -H 'Content-Type: application/json' -d "{ text: \"${{ inputs.owner-ids }} ${{ inputs.task }} <${{ inputs.failure-url }}|${{ inputs.outcome-description }}> on ${{ inputs.branch }} \"}" || true

View File

@@ -61,13 +61,13 @@ jobs:
continue-on-error: ${{ inputs.expected_to_fail }}
- name: Check out send notification action
uses: actions/checkout@v4
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
with:
path: ci
ref: ci
sparse-checkout: .github/actions/send-notification
- name: Determine owner ID secret names
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
run: |
projectName=$(echo ${{ inputs.project }} | tr '[:lower:]:-' '[:upper:]__')
groupName=$(echo $projectName | awk '{print substr($1, 0, index($1, "_") - 1)}')
@@ -75,10 +75,11 @@ jobs:
echo SECRET_NAME_OWNER_IDS_GROUP=OWNER_IDS_${groupName} >> $GITHUB_ENV
- name: Send notification
uses: ./ci/.github/actions/send-notification
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
with:
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
task: ${{ inputs.project }}:${{ inputs.task }}
owner-ids: ${{ secrets[env.SECRET_NAME_OWNER_IDS_PROJECT] || secrets[env.SECRET_NAME_OWNER_IDS_GROUP]}}
branch: ${{ inputs.checkout_ref }}
failure-url: ${{ steps.build.outputs.build-scan-url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
outcome-description: ${{ inputs.expected_to_fail && 'passed unexpectedly' || 'failed' }}

View File

@@ -61,13 +61,13 @@ jobs:
continue-on-error: ${{ inputs.expected_to_fail }}
- name: Check out send notification action
uses: actions/checkout@v4
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
with:
path: ci
ref: ci
sparse-checkout: .github/actions/send-notification
- name: Determine owner ID secret names
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
run: |
projectName=$(echo ${{ inputs.project }} | tr '[:lower:]:-' '[:upper:]__')
groupName=$(echo $projectName | awk '{print substr($1, 0, index($1, "_") - 1)}')
@@ -75,10 +75,11 @@ jobs:
echo SECRET_NAME_OWNER_IDS_GROUP=OWNER_IDS_${groupName} >> $GITHUB_ENV
- name: Send notification
uses: ./ci/.github/actions/send-notification
if: ${{ failure() }}
if: ${{ failure() || (steps.build.outcome == 'success' && inputs.expected_to_fail)}}
with:
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
task: ${{ inputs.project }}:${{ inputs.task }}
owner-ids: ${{ secrets[env.SECRET_NAME_OWNER_IDS_PROJECT] || secrets[env.SECRET_NAME_OWNER_IDS_GROUP]}}
branch: ${{ inputs.checkout_ref }}
failure-url: ${{ steps.build.outputs.build-scan-url || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
outcome-description: ${{ inputs.expected_to_fail && 'passed unexpectedly' || 'failed' }}