Skip to content

CI Discord Notification #2004

CI Discord Notification

CI Discord Notification #2004

Workflow file for this run

name: CI Discord Notification
on:
workflow_run:
workflows: ['CI', 'Docs']
types: [completed]
jobs:
notify:
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
name: 'CI Status - Discord Notification'
steps:
- name: Send Discord message
env:
# 🟢 has poor compatibility: https://www.unicompat.com/1F7E2
CI_STATUS: ${{ github.event.workflow_run.conclusion == 'success' && '✅' || '🔴' }}
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: Inspect Event Object
env:
EVENT: ${{ toJSON( github.event ) }}
run: echo $EVENT