Giter VIP home page Giter VIP logo

action-slack's Introduction

🚀 Slack for GitHub Actions

All Contributors

Build Status stability-frozen No Maintenance Intended

Sends a Slack notification. Simple as that.

Appearance on Slack :

Slack message

This GitHub action is part of a list of Actions that are located in an other repo. Feel free to check it out : https://github.com/Ilshidur/actions.


DEPRECATION NOTICE

Please refer to the following discussion : #255

Usage

- name: Slack notification
  env:
    SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
    SLACK_USERNAME: ThisIsMyUsername # Optional. (defaults to webhook app)
    SLACK_CHANNEL: general # Optional. (defaults to webhook)
    SLACK_AVATAR: repository # Optional. can be (repository, sender, an URL) (defaults to webhook app avatar)
  uses: Ilshidur/[email protected]
  with:
    args: 'A new commit has been pushed.' # Optional

NOTICE : for stability purposes, it is recommended to use the action with an explicit commit SHA-1 :

Arguments

The argument is the message to display in the Slack notification.

Environment variables can be interpolated in the message using brackets ({{ and }}) :

e.g.: Action called : {{ GITHUB_ACTION }}

Note : be careful to properly format your messages for Slack.

Event Payload data can also be interpolated in the message using brackets ({{ and }}) with the EVENT_PAYLOAD variable.

e.g.: Action called: {{ GITHUB_ACTION }} as {{ EVENT_PAYLOAD.pull_request.id }}

See the event types for valid payload informations.

Examples

  • args: "Hello, beautiful ! I ran a GitHub Action for you <3"
  • args: "I showed you my commit. Please respond."

Environment variables

  • SLACK_WEBHOOK (required): the Slack webhook URL (see https://api.slack.com/incoming-webhooks).
  • SLACK_USERNAME (optional) : overrides username. Defaults to the Slack webhook bot name.
  • SLACK_CHANNEL (optional) : overrides the default channel of the webhook. If not set, the message will be sent to the channel associated to the webhook.
  • SLACK_AVATAR (optional) : overrides the message avatar. Can be 'repository', 'sender' or an URL. If not set, the avatar of the Slack webhook's bot picture will be used.
  • SLACK_CUSTOM_PAYLOAD (advanced) : JSON string that sets full payload. instructions see CUSTOM_PAYLOAD

Debugging / testing / development

Developers, all you need is in the DEVELOPMENT.md file.

Contributors


Christhopher Lion

💻 🤔 📖

Alternatives

Because open source is about everyone :

https://github.com/marketplace/actions/post-slack-message

https://github.com/marketplace/actions/slack-notify

https://github.com/marketplace/actions/slack-bot-action

https://github.com/marketplace/actions/slatify

https://github.com/marketplace/actions/slack-notify-build

https://github.com/marketplace/actions/action-slack


Don't forget to 🌟 Star 🌟 the repo if you like this GitHub Action !
Your feedback is appreciated

action-slack's People

Contributors

allcontributors[bot] avatar dependabot[bot] avatar hawler avatar ilshidur avatar itsmelion avatar jpalumickas avatar mikeseese avatar renovate-bot avatar renovate[bot] avatar tsnolan23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

action-slack's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v2
  • Ilshidur/action-slack 2.1.0
  • Ilshidur/action-slack 2.1.0
  • Ilshidur/action-discord 0.3.0
  • Ilshidur/action-discord 0.3.0
npm
package.json
  • @actions/core 1.2.7
  • axios 0.21.0
  • lodash 4.17.21
  • @vercel/ncc 0.28.2
  • dotenv 8.2.0
  • eslint 7.24.0
  • eslint-plugin-node 11.1.0
  • node >=8.3.0

  • Check this box to trigger a request for Renovate to run again on this repository

Notification triggered twice

I have a setup similar to the one in this repo. But when I create a pull-request and merge it to master, the slack notification is triggered twice.

screenshot 2019-02-06 at 17 52 58

workflow "Slackbot workflow" {
  on = "push"
  resolves = ["Notify Slack (post deploy)"]
}

action "Install dependencies" {
  uses = "docker://node:10"
  runs = "yarn"
  args = "install"
}

action "Run lint" {
  uses = "docker://node:10"
  runs = "yarn"
  needs = ["Install dependencies"]
  args = "lint"
}

# Filter for master branch
action "Master" {
  needs = ["Run lint"]
  uses = "actions/bin/filter@master"
  args = "branch master"
}

action "Notify Slack (pre deploy)" {
  needs = "Master"
  uses = "Ilshidur/action-slack@5faabb4"
  secrets = ["SLACK_WEBHOOK"]
  args = "Upgrading myself! :hammer_and_wrench:"
}

action "Deploy" {
  needs = ["Notify Slack (pre deploy)"]
  uses = "actions/bin/sh@master"
  args = ["echo 'deploy'"]
}

action "Notify Slack (post deploy)" {
  needs = "Deploy"
  uses = "Ilshidur/action-slack@5faabb4"
  secrets = ["SLACK_WEBHOOK"]
  args = ":rocket done!"
}

Error when using quotes within custom payload

I am using this setup.

SLACK_CUSTOM_PAYLOAD: '{
"codebase": "Test Codebase",
"tag": "${{ env.TAG }}",
"changelog": "${{ env.CHANGELOG }}",
"releaseActor": "${{ github.actor }}"
}'

Recently the changelog had a commit message with quotes in it and the action generated an error. I am not sure why this is happening since the everything in the custom payload should be a string. Error is this "SyntaxError: Unexpected token m in JSON at position 158", the m comes right after a ". Please let me know if I am missing something here based on the how the custom payload is setup.

Retrieving Commit Message on Push

Hi,

Awesome plugin! I'm currently using this right now, but I'm having some difficulty with retrieving a Push Commit Title/Message and sending that to Slack? I'm looking at the EventType info, I only see commit[], but when I try to access it using {{EVENT_PAYLOAD .commmit}} or {{EVENT_PAYLOAD.commit[0].message}}, it fails. Would you know what the right syntax would be to send both the commit title/description?

Can't mention anyone from the notification text

Here's the sample setup

# Notifies colleagues that a PR was created, and where to find it
name: PR Ready Notification
on:
  pull_request:
    types: [ opened, reopened, ready_for_review ]

jobs:
  pr-ready-notification:
    name: PR ready Notification
    if: ${{ ! github.event.pull_request.draft }}
    runs-on: ubuntu-latest
    steps:
      - name: Slack PR Ready Notification
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} # This must be setup in the github project.
          SLACK_CHANNEL: our-private-slack-chat
        uses: Ilshidur/[email protected]
        with:
          args: |
            Hey Team @our-private-slack-chat, kindly review PR created by ${{ github.event.pull_request.user.login }} :rocket:
            > <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}> ${{ github.event.pull_request.title }}

The mention @our-private-slack-chat in the Slack channel looks like a text.
For instance, the official GitHub integration plugin for Slack doesn't have this problem and all the notifications have a correct mentions display.

Any way to fix it?

Is there a way to insert @here or @channel in args

Snippet from the workflow yaml I'm using

    steps:
      - name: Send PR details to slack for review
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          SLACK_CHANNEL: channel-name
        uses: Ilshidur/[email protected]
        with:
          args: "@here Please review the pull request {{ EVENT_PAYLOAD.pull_request.html_url }} \n \n Thanks! \n {{EVENT_PAYLOAD.pull_request.user.login}}"

The problem is @here or @channel does not notify the slack channel members(screenshot),
image

@Ilshidur, I'm wondering if there's a way to ensure perhaps @here gets recognized by slack like this,
image

Build artifacts

Hey,

any chance to attach the build artifacts to a slack message ? :)

Best regards
Sebastian

ECONNREFUSED 127.0.0.1:80

Hi!

I'm seeing the following error when trying to run this action in our Github Action steps:

ECONNREFUSED 127.0.0.1:80

Screen Shot 2019-09-25 at 2 24 36 PM

Publish docker image please!

Hi, i have to build this action using the dockerfile every run which takes 30 seconds. Can you just publish the docker image instead? It would speed everyones CI up by 20-25 seconds every run :)

Thanks!

Multiline messages not working

As per the slack message formatting guide, we can insert a newline by including the characters \n. But this seems to doesn't work in this plugin because I'm getting \n in the message.

Action - https://github.com/vineetchoudhary/AppBox-iOSAppsWirelessInstallation/blob/master/.github/main.workflow

workflow "Slack - New Issues" {
  resolves = ["Slack Notification for New Issues"]
  on = "issues"
}

action "Slack Notification for New Issues" {
  uses = "Ilshidur/action-slack@6aeb2acb39f91da283faf4c76898a723a03b2264"
  secrets = ["SLACK_WEBHOOK"]
  args = "A new issue has been added. \\nURL - {{ EVENT_PAYLOAD.issue.html_url }} \\nTitle - {{ EVENT_PAYLOAD.issue.title }} \\nBody - {{ EVENT_PAYLOAD.issue.body }}"
}

Screenshot_20190909-214921

Allow defining fully custom message

There's currently no way to suppress the first line which prints name of repository and other details which might not always be desired:

text: `${process.env.GITHUB_REPOSITORY}/${process.env.GITHUB_WORKFLOW} triggered by ${process.env.GITHUB_ACTOR} (${process.env.GITHUB_EVENT_NAME}) :\n${compiled(process.env)}`,

Security enhancements

We know how the built JS file in the dist/ dir can be corrupted/changed my bad people. E.g.: pushing malicious code when contributing.

TODO : find a way to prevent this. Maybe use a GitHub Action to automatically build it ?

[feature] publish 2 release tag as alias to 2.x.x

Thanks for creating this action, I wonder if you can update the release process to include an alias tag 2 or 3 to pointing to the whatever latest release tag, like 2.x.x or 3.x.x. So in the workflow, I can simply use Ilshidur/action-slack@2.

Let me know if that makes sense. Thanks!

Populating Args with event info

Terribly sorry if this isn't a helpful question, but how do you get information from the action event to be used in the args message? For example, I'm subscribed to issues which is super broad, everything from a changed label to a comment on an issue. How can I configure my slack message to speak to the details of a given notification?

Newline not interpreted by args?

We're having a weird issue where env vars are interpolating but we can't seem to get a newline character to work. We've tried both single and double character escapes:

      - name: Slack notification
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
        uses: Ilshidur/[email protected]
        with:
          args: 'A merge to `App.dev` has occurred successfully. \\n
          Commit ID: {{GITHUB_SHA}} \\n'
      - name: Slack notification
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
        uses: Ilshidur/[email protected]
        with:
          args: 'A merge to `App.dev` has occurred successfully. \n
          Commit ID: {{GITHUB_SHA}} \n'

For some reason the \n or \\n just show up directly in the message without being interpreted. Could you please offer some guidance here?
Also great job on the rest of your documentation. Very easy to understand.

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.