Skip to content

Discord Notification #64

Discord Notification

Discord Notification #64

Workflow file for this run

name: Discord Notification
on:
workflow_run:
workflows: ['CI', 'Docs']
types: [completed]
jobs:
notify:
# 'skipped' means the `if: ` condition wasn't fulfilled
if: ${{ github.event.workflow_run.conclusion != 'skipped' }}
runs-on: ubuntu-latest
steps:
- name: Push the notification using Discord webhook
env:
# 🟢 has poor compatibility: https://www.unicompat.com/1F7E2
CI_STATUS: ${{ github.event.workflow_run.conclusion == 'success' && '✅' || github.event.workflow_run.conclusion == 'failure' && '🔴' || github.event.workflow_run.conclusion }}
REPO_NAME: ${{ github.event.repository.name }}
GIT_BRANCH: ${{ github.event.workflow_run.head_branch }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
WORKFLOW_URL: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.html_url || '' }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# Playground: https://gist.github.com/brillout/da1ab713bda6e3c0d2ad909c1a4e80f2
run: |
curl \
-i \
-H "Accept: application/json" \
-H "Content-Type:application/json" \
-X POST \
--data "{\"content\":\"$CI_STATUS $REPO_NAME $WORKFLOW_NAME $GIT_BRANCH $WORKFLOW_URL\",\"username\":\"GitHub\",\"avatar_url\":\"https://i.imgur.com/OOtUMJD.png\"}" \
$DISCORD_WEBHOOK
- name: Debug/inspect
env:
EVENT: ${{ toJSON( github.event ) }}
run: echo $EVENT