Skip to content

Add Slack Notification step #70

Add Slack Notification step

Add Slack Notification step #70

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: ${{ job.status }}
fields: workflow,job,commit,repo,ref,author,took
custom_payload: |
{
attachments: [
{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} ${{ job.status }} in ${process.env.AS_TOOK}`,
}
]
}
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