Git Product home page Git Product logo

action-slacker's Introduction

Actions Status

Slack - Github Action

A Github Action to send a message to a Slack channel that supports attachments like images.

Configuration

You must set SLACK_WEBHOOK environment value in settings page of your repository in order to use without any problem. Please see here to learn how to do it if you don't know already.

Usage

Create a workflow, set a step that uses this action and don't forget to specify SLACK_WEBHOOK environment value.

name: Notification on push

on:
  push:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Slack notification
      env:
        SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
      uses: cemkiy/action-slacker@master
      with:
        # requirements fields for slack
        channel: '#channel-name'
        icon_url: 'slack user icon url'
        username: 'slack username'
        # attachment fields(not required)
        fallback: 'Required plain-text summary of the attachment.'
        color: '#36a64f'
        pretext: 'Optional text that appears above the attachment block'
        author_name: 'John Doe'
        author_link: 'http://jdoe.com/me/'
        author_icon: 'http://imageurl.com/icons/icon.jpg'
        title: 'Slack API Documentation'
        title_link: 'https://api.slack.com/'
        text: 'Optional text that appears within the attachment'
        image_url: 'http://my-website.com/path/to/image.jpg'
        thumb_url: 'http://example.com/path/to/thumb.png'
        footer: 'Slack API'
        footer_icon: 'https://platform.slack-edge.com/img/default_application_icon.png'

Output

Default output if you've not set any attachment will look like this.

Image of screenshot

If you've set an attachment, you should see it in addition to default message.

Advanced Usage

If you want to show different messages based on succes or failure of previous steps in your workflow, use success and failure functions.

- name: Slack notification Failure
  if: failure()
  env:
    SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
  uses: cemkiy/action-slacker@master
  with:
    channel: '#channel-name'
    icon_url: 'slack user icon url'
    username: 'slack username'
    image_url: 'http://my-website.com/path/to/failure.jpg'

- name: Slack notification Success
  if: success()
  env:
    SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
  uses: cemkiy/action-slacker@master
  with:
    channel: '#channel-name'
    icon_url: 'slack user icon url'
    username: 'slack username'
    image_url: 'http://my-website.com/path/to/success.jpg'

Contributing

Please see API documentation in addition to source code in this repository.

License

MIT © 2019 Cem Kıy

Does this interest you?

Join us at Biges R&D where we create software and hardware for physical security needs.

action-slacker's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.