From fa635adb7f77fa3671e3a73b89735aad8ae500ed Mon Sep 17 00:00:00 2001 From: mistermalm <45939401+mistermalm@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:19:08 +0100 Subject: [PATCH] build: smoke test webhook (#830) * build: wip * fix: content now visible in post * chore: updated button text * ci: webbhook to post failure in teams channel --- .../{smoketest-all.yml => smoke-test-all.yml} | 3 + .../workflows/smoke-test-failure-webhook.yml | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+) rename .github/workflows/{smoketest-all.yml => smoke-test-all.yml} (98%) create mode 100644 .github/workflows/smoke-test-failure-webhook.yml diff --git a/.github/workflows/smoketest-all.yml b/.github/workflows/smoke-test-all.yml similarity index 98% rename from .github/workflows/smoketest-all.yml rename to .github/workflows/smoke-test-all.yml index fdf87296e..3ff350718 100644 --- a/.github/workflows/smoketest-all.yml +++ b/.github/workflows/smoke-test-all.yml @@ -213,3 +213,6 @@ jobs: - name: Check results run: | echo "All previous jobs have completed successfully!" + - name: Notify in Teams on failure + if: failure() + uses: ./.github/workflows/smoke-test-webhook.yml diff --git a/.github/workflows/smoke-test-failure-webhook.yml b/.github/workflows/smoke-test-failure-webhook.yml new file mode 100644 index 000000000..bc2219cef --- /dev/null +++ b/.github/workflows/smoke-test-failure-webhook.yml @@ -0,0 +1,63 @@ +name: 'ci: smoke test failure webhook' + +on: + push: + branches: + - build/smoketest-webhook + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Post failure in Teams channel + env: + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + REPO_NAME: ${{ github.repository }} + BRANCH_NAME: ${{ github.ref }} + COMMIT_SHA: ${{ github.sha }} + RUN_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + run: | + curl -H 'Content-Type: application/json' -d '{ + "type": "message", + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "content": { + "type": "AdaptiveCard", + "version": "1.0", + "body": [ + { + "type": "TextBlock", + "size": "Medium", + "weight": "Bolder", + "text": "Build Failure Notification" + }, + { + "type": "FactSet", + "facts": [ + { + "title": "Repository", + "value": "'"${REPO_NAME}"'" + }, + { + "title": "Branch", + "value": "'"${BRANCH_NAME}"'" + }, + { + "title": "Commit", + "value": "'"${COMMIT_SHA}"'" + } + ] + } + ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "View failed run", + "url": "'"${RUN_URL}"'" + } + ] + } + } + ] + }' "$TEAMS_WEBHOOK_URL"