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.
To run this action you'll need:
- To be part of the Actions beta. Note that during the beta, Actions will only run on private repositories.
- A SendGrid API Key. SendGrid is free to up 100 e-mails a day so feel free to register and get your API KEY.
- A text file hosted anywhere with the list of e-mail recipients. I personally use GitHub Gists and get the link of the raw file.
Add a new workflow to your .github/main.workflow
to trigger on release
.
Create an action that uses this repository bitoiu/release-notify-action@master
or points to Docker Hub at docker://bitoiu/release-notifiy-action
Using the Visual Editor create a new secret on the action named SENDGRID_API_TOKEN
. Set the value to your SendGrid API Key.
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.
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:
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.
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) you can just run something like:
docker run -e SENDGRID_API_TOKEN=XXX -e RECIPIENTS=HOSTED_FILE_WITH_EMAILS -e GITHUB_EVENT_PATH="/notify-action/sample-payload.json" -it $(docker build -q .)
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.
❤️