From 37e1786aa508421c3d6ae3fda8432db0cbc964bd Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Sat, 18 May 2024 17:43:28 -0500 Subject: [PATCH] Consolidate Discord notification steps --- .github/workflows/deploy.yml | 20 +++++--------------- .github/workflows/notify.yml | 25 +++++++++++++++++++++++++ .github/workflows/release.yml | 20 +++++--------------- .github/workflows/smoke.yml | 17 +++++------------ .github/workflows/test.yml | 17 +++++------------ 5 files changed, 45 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/notify.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4a3cc0e8a..6a2afddf7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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') }} diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml new file mode 100644 index 000000000..d607291e7 --- /dev/null +++ b/.github/workflows/notify.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c36b7074..4751888dc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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') }} diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 11e2f295c..419bd058b 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -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') }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 26ef827d9..4dc090937 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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') }}