Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
check-circle

GitHub Action

Slack Github Actions

v1.1.0

Slack Github Actions

check-circle

Slack Github Actions

A no-config GitHub action that notifies slack of the status of your GitHub actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Slack Github Actions

uses: iRoachie/[email protected]

Learn more about this action in iRoachie/slack-github-actions

Choose a version

Slack Github Actions

A no-config GitHub action that notifies slack of the status of your GitHub actions

Demo

Supported Triggers

We currently support:

  • pull_request
  • release
  • push (tags, commits)

Messages

All event messages will have these elements:

Base Image

  1. Build Indicator - Will be green for successful, red for failed, yellow for cancelled
  2. Author Github Profile and User - This is also a link their profile page
  3. Workflow Name - Also a link to the run
  4. Repository Name - Also a link
  5. Timestamp

Pull Requests

Pull Request

  1. Commit Hash - Also a link showing the changes between the base and ref
  2. Pull Request Number and Title - Also a link to the Pull Request

Releases

Release

  1. Commit Hash - Also a link showing all changes in the release
  2. Release Title - Also a link to the release and notes. If the release doesn't have a title the tag name will be used.

Tags

Tag

  1. Commit Hash - Also a link showing all changes since this tag and master
  2. Tag name - Also a link to the tag

Commits

Commits

  1. Commit Hash - Also a link showing combined changes of all commits for the push
  2. Head Commit name - Name of last commit in the batch (can push multiple commits). Also a link to that commit.

Usage

You can use this action after any other action, however I recommend you put it as the last one. Here is an example setup of this action for a pull request:

  1. Create a .github/workflows/test.yml file in your GitHub repo.
  2. Add the following code to the test.yml file.
name: Test

on:
  pull_request:
    branches:
      - master

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - run: npm install
      - run: npm test

      - uses: iRoachie/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        with:
          status: ${{ job.status }}
        if: ${{ always() }}
  1. Create SLACK_WEBHOOK_URL secret using GitHub Action's Secret. You can generate a Slack incoming webhook token from here.

Advanced Usage

Here's an example with jobs that run in parallel.

It does a few things:

  • Lets us know when a status check didn't succeed (failure or cancel)
  • If all jobs were successful, we'll send a message at the end
name: Test

on:
  pull_request:
    branches:
      - master

jobs:
  test:
    name: Jest
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: yarn
      - run: yarn test
      - uses: iRoachie/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        with:
          status: ${{ job.status }}
        if: ${{ !success() }}

  lint:
    name: Eslint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: yarn
      - run: yarn lint
      - uses: iRoachie/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        with:
          status: ${{ job.status }}
        if: ${{ !success() }}

  notify:
    Name: Slack
    needs: [test, lint]
    runs-on: ubuntu-latest
    steps:
      - uses: iRoachie/[email protected]
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        with:
          status: ${{ job.status }}