Notify of workflow run conclusion #11
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: 'Notify of workflow run conclusion' | |
on: | |
workflow_run: | |
workflows: | |
- 'CI/CD' | |
types: [completed] | |
jobs: | |
on-failure: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Dump GitHub event | |
env: | |
GITHUB_EVENT: ${{ toJson(github.event) }} | |
run: echo "$GITHUB_EVENT" | |
- name: 💬 Notify Telegram of workflow run FAILURE | |
# https://github.com/appleboy/telegram-action | |
uses: appleboy/[email protected] | |
with: | |
to: ${{ fromJSON(secrets.TELEGRAM).chat_id }} | |
token: ${{ fromJSON(secrets.TELEGRAM).token }} | |
format: html | |
disable_web_page_preview: true | |
# https://core.telegram.org/bots/api#formatting-options | |
message: | | |
<b>⚠️ GitHub workflow failure 💔</b> | |
Repository: <a href="${{ github.event.repository.html_url }}">${{ github.event.repository.full_name }}</a> | |
Workflow: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.name }}</a> | |
Workflow Run ID: <a href="${{ github.event.workflow_run.html_url }}?check_suite_focus=true">${{ github.event.workflow_run.id }}</a> | |
on-success: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: 💬 Notify Telegram of workflow run SUCCESS | |
uses: appleboy/[email protected] | |
with: | |
to: ${{ fromJSON(secrets.TELEGRAM).chat_id }} | |
token: ${{ fromJSON(secrets.TELEGRAM).token }} | |
format: html | |
disable_web_page_preview: true | |
message: | | |
<b>✅ GitHub workflow success 💖</b> | |
Repository: <a href="${{ github.event.repository.html_url }}">${{ github.event.repository.full_name }}</a> | |
Workflow: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.name }}</a> | |
Workflow Run ID: <a href="${{ github.event.workflow_run.html_url }}?check_suite_focus=true">${{ github.event.workflow_run.id }}</a> |