Skip to content

Add Slack Notification step #74

Add Slack Notification step

Add Slack Notification step #74

Workflow file for this run

name: CI Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
strategy:
fail-fast: false
matrix:
# ruby: ['3.0', '3.2', head, jruby-head]
ruby: ['3.0', '3.2', head]
operating-system: [ubuntu-latest]
# include:
# - ruby: '3.0'
# operating-system: windows-latest
# - ruby: jruby-head
# operating-system: windows-latest
name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run rake
run: bundle exec rake
- name: Fail if building with Ruby 3.0
if: matrix.ruby == '3.0'
run: exit 1
# - name: Slack Failure Notification
# uses: 8398a7/action-slack@v3
# with:
# status: ${{ job.status }}
# author_name: Build
# fields: all
# mention: here
# if_mention: 'failure, cancelled'
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
# if: failure() # Pick up events even if the job fails or is canceled.
# - name: Slack Failure Notification
# uses: 8398a7/action-slack@v3
# with:
# status: custom
# custom_payload: |
# {
# attachments: [
# {
# color: 'danger',
# text: 'Build failed!'
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
# if: failure() # Pick up events even if the job fails or is canceled.
- name: Slack Failure Notification
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
"attachments": [
{
"color": "${{ job.status }}",
"title": >-
${{ github.actor }} ${{ github.event.pull_request && github.event.pull_request.merged == true && 'merged a pull request' || github.event.pull_request && 'opened a pull request' || github.event_name == 'push' && 'pushed new changes' || github.event_name == 'create' && 'created a new branch or tag' || github.event_name == 'delete' && 'deleted a branch or tag' || github.event_name == 'issues' && github.event.action || 'triggered an event' }},
"text": >-
:tada: Event details:
- Repository: ${{ github.repository }}
- Branch: ${{ github.ref }}
- Message: ${{ github.event_name == 'push' && github.event.head_commit.message || github.event_name == 'issues' && github.event.issue.title || github.event_name == 'pull_request' && github.event.pull_request.title || '' }}
- :globe_with_meridians: Link: ${{ github.event.pull_request.html_url || github.event.issue.html_url || github.event.repository.html_url }}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: failure() # Pick up events even if the job fails or is canceled.
coverage:
needs: [ build ]
runs-on: ubuntu-latest
name: Report test coverage to CodeClimate
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run tests
run: bundle exec rake spec
- name: Report test coverage
uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: f0b6388a435f5b93101b27edc5c7fb8d5db2ee6f38216f5e4eeb9e1caf686afa
with:
coverageLocations: ${{github.workspace}}/coverage/lcov/*.lcov:lcov