From 164de0af0dd250d676b6356200aa913bb1a91a0c Mon Sep 17 00:00:00 2001 From: Uruk Date: Thu, 9 Oct 2025 13:41:19 +0200 Subject: [PATCH] feat: add workflow failure notifications to Discord Extends the Discord notification system to monitor and report workflow failures in addition to pull requests. Adds a new workflow_run trigger that listens for completed workflows on the develop branch and sends Discord notifications when any workflow fails. Separates notification logic into two jobs: one for pull request events and another for workflow failures, each with appropriate conditional guards and using different webhook URLs for distinct notification channels. Renames the workflow from "Discord Pull Request Notification" to "Discord Notification" to reflect the expanded scope. --- .github/workflows/notification.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/notification.yml b/.github/workflows/notification.yml index f9159919..92bb4a5d 100644 --- a/.github/workflows/notification.yml +++ b/.github/workflows/notification.yml @@ -1,13 +1,18 @@ -name: 🛎️ Discord Pull Request Notification +name: 🛎️ Discord Notification on: pull_request: types: [opened, reopened] branches: [develop] + workflow_run: + workflows: ["*"] + types: [completed] + branches: [develop] jobs: notify: runs-on: ubuntu-24.04 + if: github.event_name == 'pull_request' steps: - name: 🛎️ Notify Discord uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0 @@ -21,3 +26,21 @@ jobs: **By:** ${{ github.event.pull_request.user.login }} **Branch:** ${{ github.event.pull_request.head.ref }} 🔗 ${{ github.event.pull_request.html_url }} + + notify-on-failure: + runs-on: ubuntu-24.04 + if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' + steps: + - name: 🚨 Notify Discord on Failure + uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0 + env: + DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_FAILED_JOB_URL }} + DISCORD_AVATAR: https://avatars.githubusercontent.com/u/193271640 + with: + args: | + 🚨 **Workflow Failed** in **${{ github.repository }}** + **Workflow:** ${{ github.event.workflow_run.name }} + **Branch:** ${{ github.event.workflow_run.head_branch }} + **Triggered by:** ${{ github.event.workflow_run.triggering_actor.login }} + **Commit:** ${{ github.event.workflow_run.head_commit.message }} + 🔗 ${{ github.event.workflow_run.html_url }}