Skip to content

Slack Build Notifications #9092

Slack Build Notifications

Slack Build Notifications #9092

name: Slack Build Notifications
on:
workflow_run:
workflows:
[
Add To Project,
Version,
Release,
Deploy React storybook to GitHub Pages,
promote,
]
types: [completed]
branches: [main]
jobs:
on-success:
runs-on: ubuntu-latest
# We only want notifications for successful runs for certain workflows
if:
${{ github.event.workflow_run.conclusion == 'success' &&
contains(fromJson('["Version", "Release", "Deploy React storybook to
GitHub Pages", "promote"]'), github.event.workflow.name) }}
steps:
- name: Send custom JSON data to Slack
id: slack-success
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e #v1.26.0
with:
payload: |
{
"username": "Workflow succeeded ✅",
"icon_url": "https://user-images.githubusercontent.com/3360588/192045905-5d9705af-92e2-4432-805e-15db98571e8b.png",
"channel": "#carbon-system-notifications",
"text": "The ${{ github.event.workflow.name }} workflow succeeded: ${{ github.event.workflow_run.url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Send custom JSON data to Slack
id: slack-failure
uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e #v1.26.0
with:
payload: |
{
"username": "Workflow failed 🚫",
"icon_url": "https://user-images.githubusercontent.com/3360588/192045905-5d9705af-92e2-4432-805e-15db98571e8b.png",
"channel": "#carbon-system-notifications",
"text": "The ${{ github.event.workflow.name }} workflow failed: ${{ github.event.workflow_run.url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK