Sign inSign up

bitoiu/release-notify-action

By bitoiu

•Updated over 7 years ago

GitHub Action that integrates SendGrid to auto e-mail a list of recipients upon release creation.

Image
0

10K+

bitoiu/release-notify-action repository overview

⁠release-notify-action

This repo contains a re-usable GitHub Action that when installed sends an e-mail to a distribution list with the release note contents every time a GitHub Release is created for the repository.

This Action makes use of SendGrid's⁠ API to send the e-mails.

⁠Pre-requisites

To run this action you'll need:

⁠Setup

⁠1. Create the release workflow

Add a new workflow to your .github/main.workflow to trigger on release.

new-workflow
⁠2. Create the Action

Create an action that uses this repository bitoiu/release-notify-action@master or points to Docker Hub at docker://bitoiu/release-notifiy-action

new-action
⁠3. Set the SendGrid secret

Using the Visual Editor create a new secret on the action named SENDGRID_API_TOKEN. Set the value to your SendGrid API Key⁠.

new-secret
⁠4. Set the RECIPIENTS secret

Do the same for a secret named RECIPIENTS that you need to set to the URI of the text file with the target recipients. The contents of the file should be a list of e-mails separated by newline, for example:

If you don't know where to host this file, just go to GitHub Gists⁠ and create a new textfile with the e-mails you want to target. After you save the file just click raw and get the URI of the file you've just created.

⁠5. Commit the changes

Make sure you commit all pending changes. After you've done that your main.workflow should look similar to this:


workflow "Release Notifier" {
  on = "release"
  resolves = ["Notify Releases"]
}

action "Notify Releases" {
  uses = "bitoiu/release-notify-action@master"
  secrets = ["SENDGRID_API_TOKEN", "RECIPIENTS"]
}

On the visual editor it should look similar to this:

visual editor

⁠6. Test the workflow!

Create a new release for your repository and verify that the action triggers and that the e-mails were sent. Sometimes it's worth checking the spam inbox.

⁠Local testing

The main script that does the heavy lifting is a NodeJS file. As such you can simply test it like any other node program, for example, running the following inside the src folder:

SENDGRID_API_TOKEN=XXX RECIPIENTS=ABSOLUTE_PATH_TO_TXT_FILE_WITH_RECIPIENTS GITHUB_EVENT_PATH=ABSOLUTE_PATH_TO_SAMPLE_PAYLOAD_FILE_PROVIDED node notify.js

If you prefer to test the container directly (which is a tiny bit slower but more reliable) you can just run something like:

docker build -t release . && docker run --env-file=./env release

Be sure to rename env.template to env and fill it with your environment variables.

⁠Pull Requests and Issues are Welcome

If you're thinking of a dynamic e-mail template with substitutions, configurable TO and FROM addresses then you're just a pull request away. Feel free to share your ideas.

:octocat::heart:

Tag summary

Content type

Image

Digest

Size

22.4 MB

Last updated

over 7 years ago

docker pull bitoiu/release-notify-action