From 714a95aa823fadd7edef4751d8882c3f07a9681e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 28 Feb 2024 11:46:47 +0000 Subject: [PATCH] Pass job status into send-notification action --- .github/actions/send-notification/action.yml | 11 +++++++---- .github/workflows/windows-build.yml | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/send-notification/action.yml b/.github/actions/send-notification/action.yml index 1f857bfd811..eef0a1c0395 100644 --- a/.github/actions/send-notification/action.yml +++ b/.github/actions/send-notification/action.yml @@ -4,6 +4,9 @@ inputs: webhook-url: description: 'Google Chat Webhook URL' required: true + status: + description: 'Status of the job' + required: true build-scan-url: description: 'URL of the build scan to include in the notification' run-name: @@ -17,14 +20,14 @@ runs: echo "BUILD_SCAN=${{ inputs.build-scan-url == '' && ' [build scan unavailable]' || format(' [<{0}|Build Scan>]', inputs.build-scan-url) }}" >> "$GITHUB_ENV" echo "RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> "$GITHUB_ENV" - shell: bash - if: ${{ success() }} + 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 ${{ env.BUILD_SCAN }}"}' || true - shell: bash - if: ${{ failure() }} + if: ${{ inputs.status == 'failure' }} run: | curl -X POST ${{ inputs.webhook-url }} -H 'Content-Type: application/json' -d '{ text: " *<${{ env.RUN_URL }}|${{ inputs.run-name }}> failed* ${{ env.BUILD_SCAN }}"}' || true - shell: bash - if: ${{ cancelled() }} + 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 cancalled"}' || true + curl -X POST ${{ inputs.webhook-url }} -H 'Content-Type: application/json' -d '{ text: "<${{ env.RUN_URL }}|${{ inputs.run-name }}> was cancelled"}' || true diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 187cb31f612..7552d71deb1 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -52,5 +52,6 @@ jobs: if: always() with: webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} + status: ${{ job.status }} build-scan-url: ${{ steps.build.outputs.build-scan-url }} run-name: ${{ format('{0} | Windows | Java 17', github.ref_name) }}