• Stars
    star
    252
  • Rank 161,312 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created about 5 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Report GitHub Actions build status on Slack

Slack Notify Build

This action prints your GitHub Action build status to Slack. It takes an opinionated approach by showing attachments for metadata like branch, pull request, and event. This action allows existing messages to be updated to reduce unwanted noise in your Slack channel. Heavily-inspired by Post Slack messages.

A Slack bot token is required to use this action, and the associated app must be granted permission to post in the channel, private group or DM you specify.

Usage

uses: voxmedia/github-action-slack-notify-build@v1
with:
  channel: app-alerts
  status: STARTED
  color: good
env:
  SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}

The Slack notification leverages attachments to group important information together and provide valuable links:

Screenshot of the push event

When used with the pull_request event, a link to the originating pull request is included:

Screenshot of the pull_request event

Updating an Existing Message

If you need to send multiple Slack build updates and you prefer to update a single message instead of posting multiple messages, you can pass a message_id to future steps.

Updating existing messages

Note: You must assign a step id to the first Slack notification step in order to reference it for future steps:

- name: Notify slack success
  if: success()
  id: slack # IMPORTANT: reference this step ID value in future Slack steps
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    channel: app-alerts
    status: STARTING
    color: warning

- name: Run tests
  # ... your test step here
- name: Notify slack success
  if: success()
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    # Updates existing message from the first step
    message_id: ${{ steps.slack.outputs.message_id }}
    channel: app-alerts
    status: SUCCESS
    color: good

Reporting Success or Failure

You can use the success() and failure() conditional checks within your workflow to determine which build notification to send:

- name: Run tests
  # ... your test step here
- name: Notify slack success
  if: success()
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    channel: app-alerts
    status: SUCCESS
    color: good

- name: Notify slack fail
  if: failure()
  env:
    SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }}
  uses: voxmedia/github-action-slack-notify-build@v1
  with:
    channel: app-alerts
    status: FAILED
    color: danger

Inputs

status

Required The status to show for the action, e.g. STARTED or FAILED.

channel

The name of the channel to post the message to. Required if no channel_id is provided.

Note: If your workspace has many channels, supplying only a channel may cause rate limiting issues with this GitHub Action. Consider supplying a channel_id instead.

channel_id

The ID of the channel to post the message to. Required if no channel is provided, or if you need to send to a DM.

color

The color to use for the notification. Can be a hex value or any valid Slack color level (e.g. good). Defaults to #cccccc.

message_id

The ID of a previous Slack message to update instead of posting a new message. Typically passed using the steps context:

message_id: ${{ steps.<your_first_slack_step_id>.outputs.message_id }}

Outputs

message_id

Returns the unique message ID, which is a timestamp which can be passed to future Slack API calls as ts.

Setup

To use this GitHub Action, you'll need a Slack bot token. A bot token must be associated with a Slack app.

Creating a Slack App

  1. Create a Slack App. Go to Slack's developer site then click "Create an app". Name the app "GitHub Action" (you can change this later) and make sure your team's Slack workspace is selected under "Development Slack Workspace".
  2. Add a Bot user. Browse to the "Bot users" page listed in the sidebar. Name your bot "GitHub Action" (you can change this later) and leave the other default settings as-is.
  3. Set an icon for your bot. Browse to the "Basic information" page listed in the sidebar. Scroll down to the section titled "Display information" to set an icon.
  4. Install your app to your workspace. At the top of the "Basic information" page, you can find a section titled "Install your app to your workspace". Click on it, then use the button to complete the installation.

Slack App OAuth Scopes

In order to use your Slack App with this GitHub Action, be sure to enable the following OAuth scopes:

Scope Required?
chat:write Yes
channels:read If using channel instead of channel_id
groups:read If using channel instead of channel_id

License

The scripts and documentation in this project are released under the Apache 2.0 License.

More Repositories

1

meme

Meme generator
JavaScript
1,849
star
2

autotune

Platform for reusable news tools
JavaScript
414
star
3

data-projects

Scripts and data for various Vox Media stories and news projects
Jupyter Notebook
185
star
4

metronome

JavaScript
170
star
5

middleman-google_drive

Middleman extension for loading content from Google Drive
Ruby
137
star
6

verge-50

An example of a Middleman-powered editorial app built by the Vox Media Product Team and published by The Verge.
CSS
129
star
7

accessibility

Vox Product's Accessibility Guidelines
HTML
90
star
8

quiz-generator

JavaScript
88
star
9

lightbike

Asset budget auditing library - for internet site webpages
JavaScript
67
star
10

gliss

Constraint based article layout system
HTML
63
star
11

mapper

A tool for generating world and US-state choropleth maps
JavaScript
51
star
12

Transcriber

NWJS os x desktop based application that given a video/audio file returns a transcription using IBM Watson Speech to text API
HTML
41
star
13

viz-app

GUI for ai2html
HTML
38
star
14

code-of-conduct

HTML
37
star
15

vax-fig

jQuery plugin that downloads and displays the first frame of an animated GIF
JavaScript
35
star
16

tonr

Vax 16 project by Pam, Brittany, Alesha, Scott, and Aidan
JavaScript
27
star
17

sass-theme-template-loader

Themed CSS stylesheet generator for Sass assets
JavaScript
13
star
18

maestro

Maestro - the BigQuery Orchestrator
Go
13
star
19

revenue-hiring

Hiring Guide and Programming Examples
Ruby
11
star
20

pixelpunch

http://pixelpunch.voxmedia.com
HTML
9
star
21

ad-server-proxy

Ruby
8
star
22

captions_burner

NWJS os x desktop app that given a srt and a video burns the captions onto the video. Can also export as gif.
HTML
8
star
23

concert-vast

A simple VAST Library
JavaScript
7
star
24

yobot

Yo.
Ruby
6
star
25

autotune-image-slider

JavaScript
6
star
26

vox-hiring-exercise

Ruby
6
star
27

tap-instagram

Singer Tap for the Instagram Graph API
Python
5
star
28

rich-text-ruby

Format for representing rich text documents and changes, ported from https://github.com/ottypes/rich-text
Ruby
5
star
29

bongo

Bongo is a responsive tool that quickly enables people to make type pairings, color, branding and photo choices in a live, responsive environment without writing any code.
Ruby
4
star
30

autotune-wtfengine

WTFEngine for Autotune
JavaScript
4
star
31

canonical_domain

Ruby
4
star
32

data-privacy-compliance

Vox Media's library for implementing data privacy frameworks for use in revenue
JavaScript
4
star
33

eslint-config-voxproduct

Eslint config for js projects
JavaScript
3
star
34

setup-vox-rig

Script for setting up your Mac OS X system to make Vox Media middleman apps (should be public)
Shell
3
star
35

kinto_box

A ruby client for Kinto(kinto.readthedocs.io)
Ruby
3
star
36

varniphite

Go
3
star
37

voxholder

Ruby
3
star
38

thumbor_varnish_http_loader

Python
2
star
39

ida

Vax project 2016 - Rethinking Visual Narratives
JavaScript
2
star
40

DevOps-Technical-Exercise

Ruby
2
star
41

tap-elasticsearch

meltano extractor for elastic search
Python
2
star
42

tap-twitter

Meltano extractor for organic data from the Twitter API
Python
2
star
43

image_compression_experiments

JavaScript
2
star
44

vc-ikea-minisite

Ikea Minisite 2020
HTML
1
star
45

thumbor_indexed_file_result_storage

Python
1
star
46

nginxplusphite

Puts nginx plus status on graphite
Go
1
star
47

omniauth_service

Ruby
1
star
48

tap-facebook-pages

Singer tap for organic Facebook content insights built using the Meltano SDK
Python
1
star
49

tap-google-sheets

Meltano extractor for Google Sheets
Python
1
star
50

identity-library

Simple JavaScript library to generate private identifiers
TypeScript
1
star
51

iframe-client

Cross-origin iframe messaging client
JavaScript
1
star
52

tap-firestore

Singer Tap for Firestore built with the Meltano SDK
Python
1
star
53

thumbor_rewrite_loader

An HTTP loader which rewrites matches from a list, with a single canonical domain.
Python
1
star
54

attribute_delegator

An ActiveRecord extension that allows you to treat fields from another model/table as local attributes.
Ruby
1
star
55

open-source-contribution-guidelines

Guidelines and code of conduct for contributing to Vox Media open source projects.
1
star