CI Discord Notification #2004
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |