Skip to content

Notification

Notification #1930

Workflow file for this run

name: Notification
on:
workflow_run:
branches: [main]
workflows:
- "CI"
- "CodeQL"
- "Fossa"
- "Lint"
types:
- completed
permissions:
contents: read
jobs:
on-failure:
runs-on: ubuntu-24.04
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
permissions:
contents: read
actions: read # for 8398a7/action-slack
steps:
- name: Data
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
continue-on-error: true
id: data
with:
script: |
const message = context.payload.workflow_run.head_commit.message
message_sanitized = message.split('\n')[0]
const check_data = (await github.rest.checks.listForRef({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
ref: context.payload.workflow_run.head_commit.id,
})).data.check_runs.filter(check_run => check_run.conclusion === 'failure')[0]
return {
job_name: check_data.name,
job_url: check_data.html_url,
commit_message: message_sanitized,
}
- name: Send Notification
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: custom
custom_payload: |
{
username: 'Github',
icon_emoji: ':github:',
mention: 'channel',
attachments: [{
title: '[${{ github.event.repository.full_name }}] ${{ github.event.workflow.name }} pipeline has failed (${{ github.event.workflow_run.event }})',
color: 'danger',
fields: [{
title: 'Commit',
value: `<https://github.com/${{ github.repository }}/commit/${{ github.event.workflow_run.head_commit.id }}|${{ fromJSON(steps.data.outputs.result).commit_message }}>`,
short: true
},
{
title: 'Failed Job',
value: `<${{ fromJSON(steps.data.outputs.result).job_url }}|${{ fromJSON(steps.data.outputs.result).job_name }}>`,
short: true
},
{
title: 'Author',
value: `${{ github.event.workflow_run.head_commit.author.name }}`,
short: true
},
{
title: 'Pipeline URL',
value: `<https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}|${{ github.event.workflow_run.id }}>`,
short: true
}]
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}