Github Workflow Run Completed Notification to Slack & Email
Use the Github integration by MagicBell to setup a workflow when workflow_run triggers in Github.
Connect Github to MagicBell to receive events and trigger workflows. This guide uses the MagicBell CLI.
Add the Github integration
Save your Github webhook signing secret in MagicBell. See GitHub webhooks.
magicbell integration save_github \
--data '{"webhook_signing_secret":"your_secret_here"}'Copy the ID from the response and use it to build your webhook URL:
https://api.magicbell.com/v2/integrations/github/webhooks/incoming/{id}Setup the webhook
- Setup a webhook in Github with the URL from the last step.
- Select the workflow_run event.
- If you already have a webhook configured, make sure it includes this event.
Add a workflow
Create a workflow that triggers automatically when Github sends this event.
Workflow key
Use this key to trigger the workflow when Github sends a workflow_run event:
integration.github.workflow_runFilter by action: GitHub sends the event type in the header and the action in the payload body. Use an if condition to filter for the completed action:
"if": "payload.action == 'completed'"Example workflow
Notify when GitHub Actions workflows complete. Notify the team on deployment success or failure.
{
"key": "integration.github.workflow_run",
"steps": [
{
"if": "payload.action == 'completed'",
"command": "broadcast",
"input": {
"action_url": "{{payload.workflow_run.html_url}}",
"content": "Workflow #{{payload.workflow_run.run_number}} on {{payload.workflow_run.head_branch}} in {{payload.repository.full_name}} has {{payload.workflow_run.conclusion}}.",
"overrides": {
"providers": {
"email": {},
"slack": {}
}
},
"recipients": [
{
"external_id": "devops-team"
}
],
"title": "{{payload.workflow_run.name}} {{payload.workflow_run.conclusion}}"
}
}
]
}Save with the CLI
Use the MagicBell CLI to save this workflow to your project. You can also use the Workflows API endpoint instead.
magicbell workflow save \
--data '{"key":"integration.github.workflow_run","steps":[{"if":"payload.action == 'completed'","command":"broadcast","input":{"action_url":"{{payload.workflow_run.html_url}}","content":"Workflow #{{payload.workflow_run.run_number}} on {{payload.workflow_run.head_branch}} in {{payload.repository.full_name}} has {{payload.workflow_run.conclusion}}.","overrides":{"providers":{"email":{},"slack":{}}},"recipients":[{"external_id":"devops-team"}],"title":"{{payload.workflow_run.name}} {{payload.workflow_run.conclusion}}"}}]}'Event payload
Sample payload for the workflow_run event. Use liquid templates to access fields in your workflow.
{
"action": "completed",
"organization": {
"avatar_url": "https://avatars.githubusercontent.com/u/111111",
"description": "Building great software",
"id": 111111,
"login": "acme"
},
"repository": {
"default_branch": "main",
"full_name": "acme/project",
"html_url": "https://github.com/acme/project",
"id": 987654321,
"name": "project",
"node_id": "MDEwOlJlcG9zaXRvcnk5ODc2NTQzMjE=",
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/111111",
"html_url": "https://github.com/acme",
"id": 111111,
"login": "acme",
"type": "Organization"
},
"private": false,
"visibility": "public"
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/234567",
"html_url": "https://github.com/john-dev",
"id": 234567,
"login": "john-dev",
"node_id": "MDQ6VXNlcjIzNDU2Nw==",
"type": "User"
},
"workflow": {
"created_at": "2024-01-01T00:00:00Z",
"html_url": "https://github.com/acme/project/actions/workflows/deploy.yml",
"id": 111222333,
"name": "Deploy to Production",
"node_id": "W_kwDOABC123",
"path": ".github/workflows/deploy.yml",
"state": "active",
"updated_at": "2025-01-01T00:00:00Z",
"url": "https://api.github.com/repos/acme/project/actions/workflows/111222333"
},
"workflow_run": {
"actor": {
"avatar_url": "https://avatars.githubusercontent.com/u/234567",
"id": 234567,
"login": "john-dev",
"type": "User"
},
"check_suite_id": 987654321,
"check_suite_node_id": "CS_kwDOABC123",
"conclusion": "success",
"created_at": "2025-01-15T18:00:00Z",
"display_title": "Deploy to Production",
"event": "push",
"head_branch": "main",
"head_commit": {
"author": {
"email": "john@example.com",
"name": "John Dev"
},
"committer": {
"email": "noreply@github.com",
"name": "GitHub"
},
"id": "abc123def456789012345678901234567890abcd",
"message": "Merge pull request #123 from feature/oauth2-auth",
"timestamp": "2025-01-15T17:55:00Z",
"tree_id": "tree123abc456def789012345678901234567890"
},
"head_repository": {
"full_name": "acme/project",
"id": 987654321,
"name": "project"
},
"head_sha": "abc123def456789012345678901234567890abcd",
"html_url": "https://github.com/acme/project/actions/runs/123456789",
"id": 123456789,
"jobs_url": "https://api.github.com/repos/acme/project/actions/runs/123456789/jobs",
"logs_url": "https://api.github.com/repos/acme/project/actions/runs/123456789/logs",
"name": "Deploy to Production",
"node_id": "WFR_kwDOABC123",
"path": ".github/workflows/deploy.yml",
"pull_requests": [],
"run_attempt": 1,
"run_number": 42,
"run_started_at": "2025-01-15T18:00:00Z",
"status": "completed",
"triggering_actor": {
"avatar_url": "https://avatars.githubusercontent.com/u/234567",
"id": 234567,
"login": "john-dev",
"type": "User"
},
"updated_at": "2025-01-15T18:15:00Z",
"url": "https://api.github.com/repos/acme/project/actions/runs/123456789",
"workflow_id": 111222333
}
}