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 18, 2024
1 parent b7a1c93 commit 37e1786
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 54 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,15 @@ 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()
runs-on: ubuntu-latest
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') }}
25 changes: 25 additions & 0 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Send Discord Notification

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

jobs:
notify:
runs-on: ubuntu-latest
steps:
- env:
WORKFLOW_NAME: ${{ inputs.name }}
WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK }}
HOOK_OS_NAME: ${{ runner.os }}
if: env.WEBHOOK_URL
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' }} $WEBHOOK_URL
20 changes: 5 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,16 @@ 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()
runs-on: ubuntu-latest
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') }}
17 changes: 5 additions & 12 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,10 @@ jobs:
notify:
needs:
- smoke-test-inflator
runs-on: ubuntu-latest
if: failure()
runs-on: ubuntu-latest
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') }}
17 changes: 5 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,10 @@ jobs:
notify:
needs:
- test-build
runs-on: ubuntu-latest
if: failure()
runs-on: ubuntu-latest
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') }}

0 comments on commit 37e1786

Please sign in to comment.