Skip to content

Commit

Permalink
Update Slack notifications (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
martialonline committed Sep 28, 2020
1 parent 58271f9 commit e2add4b
Showing 1 changed file with 52 additions and 14 deletions.
66 changes: 52 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Continuous Integration
on:
push:
branches:
- '**'
- master
pull_request:
branches:
- master
Expand Down Expand Up @@ -49,19 +49,57 @@ jobs:
env:
NGINX_PLUS_VERSION: nightly

job-failure:
name: Report Failures
notify:
name: Notify
runs-on: ubuntu-18.04
if: failure()
needs: build
if: always() && github.ref == 'refs/heads/master'
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@master
- name: Workflow Status
id: check
uses: martialonline/workflow-status@v1
- name: Output Variables
id: commit
run: |
echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
echo "::set-output name=repo::$(echo ${GITHUB_REPOSITORY} | cut -d '/' -f 2)"
- name: Send Notification
uses: 8398a7/action-slack@v3
if:
steps.check.outputs.status == 'failure' ||
steps.check.outputs.status == 'cancelled'
with:
status: custom
custom_payload: |
{
username: 'Github',
icon_emoji: ':octocat:',
mention: 'channel',
attachments: [{
title: '${{ steps.commit.outputs.repo }} ${{ github.workflow }} pipeline has failed',
color: '${{ steps.check.outputs.status }}' == 'failure' ? 'danger' : 'warning',
fields: [{
title: 'Commit Hash',
value: '${{ steps.commit.outputs.sha }}',
short: true
},
{
title: 'Author',
value: '${{ github.actor }}',
short: true
},
{
title: 'Commit Message',
value: `${{ github.event.head_commit.message }}`,
short: false
},
{
title: 'Pipeline URL',
value: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}',
short: false
}]
}]
}
env:
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
SLACK_COLOR: '#3278BD'
SLACK_ICON_EMOJI: ':github:'
SLACK_TITLE: Pipeline Failure
SLACK_MESSAGE: 'The pipeline has failed, please check the logs.'
SLACK_FOOTER: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
SLACK_USERNAME: GitHub-Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_HOOK }}
GITHUB_TOKEN: ${{ github.token }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

0 comments on commit e2add4b

Please sign in to comment.