Skip to content

Commit

Permalink
Consolidate Discord notification steps
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed May 19, 2024
1 parent b7a1c93 commit 897fde5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 58 deletions.
21 changes: 5 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,14 @@ jobs:
./build docker-metadata --configuration=Release --exclusive
notify-discord:
runs-on: ubuntu-latest
needs:
- upload-deb
- upload-rpm
- upload-inflator
- upload-metadata-tester
env:
JOB_STATUS: failure
if: always()
steps:
- name: Set Success
run: echo "JOB_STATUS=success" >> $GITHUB_ENV
if: contains(needs.*.result, 'failure') == false
- name: Send Discord Notification
env:
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
if: env.WEBHOOK_URL
run: |
git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
uses: ./.github/workflows/notify.yml
with:
name: ${{ github.workflow }}
success: ${{ !contains(needs.*.result, 'failure') }}
secrets: inherit
26 changes: 26 additions & 0 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Send Discord Notification

on:
workflow_call:
inputs:
name:
type: string
required: true
success:
type: boolean
required: true
secrets:
DISCORD_WEBHOOK:
required: true

jobs:
notify:
runs-on: ubuntu-latest
steps:
- env:
WORKFLOW_NAME: ${{ inputs.name }}
HOOK_OS_NAME: ${{ runner.os }}
shell: bash
run: |
git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh ${{ inputs.success && 'success' || 'failure' }} ${{ secrets.DISCORD_WEBHOOK }}
21 changes: 5 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,15 @@ jobs:
run: gh release upload ${{ github.event.release.tag_name }} _build/repack/Release/AutoUpdater.exe

notify-discord:
runs-on: ubuntu-latest
needs:
- build-dmg
- build-deb
- build-rpm
- upload-binaries
- upload-nuget
env:
JOB_STATUS: failure
if: always()
steps:
- name: Set Success
run: echo "JOB_STATUS=success" >> $GITHUB_ENV
if: contains(needs.*.result, 'failure') == false
- name: Send Discord Notification
env:
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
if: env.WEBHOOK_URL
run: |
git clone --depth 1 https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
uses: ./.github/workflows/notify.yml
with:
name: ${{ github.workflow }}
success: ${{ !contains(needs.*.result, 'failure') }}
secrets: inherit
19 changes: 6 additions & 13 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,11 @@ jobs:
"
notify:
needs:
- build-release
- smoke-test-inflator
runs-on: ubuntu-latest
if: failure()
steps:
- name: Send Discord Notification
env:
JOB_STATUS: failure
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
if: env.WEBHOOK_URL
run: |
git clone https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
shell: bash
uses: ./.github/workflows/notify.yml
with:
name: ${{ github.workflow }}
success: ${{ !contains(needs.*.result, 'failure') }}
secrets: inherit
19 changes: 6 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,11 @@ jobs:

notify:
needs:
- build-debug
- test-build
runs-on: ubuntu-latest
if: failure()
steps:
- name: Send Discord Notification
env:
JOB_STATUS: failure
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
if: env.WEBHOOK_URL
run: |
git clone https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
shell: bash
uses: ./.github/workflows/notify.yml
with:
name: ${{ github.workflow }}
success: ${{ !contains(needs.*.result, 'failure') }}
secrets: inherit

0 comments on commit 897fde5

Please sign in to comment.