A GitHub Action to push a slack webhook
This action suits the deploy on new tag workflow.
On your release workflow, this action will post to Slack the version, a link to the workflow and the changelog (if your changelog follows this format).
Go to Slack's app manager, create a new app with an incoming webhook for the channel you want, copy the URL, that's your slack_webhook_url
. If you want to make it pretty, there's an icon in this repository you can give to your app.
The version you're releasing (e.g. v1.0.1, 1.0.1)
Optional, the contents of your changelog file.
Each version needs to start with ## x.y.z
Your slack webhook URL
- name: Get changelog
id: changelog
shell: bash
# trick for multiline variables
run: |
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$(head -100 HISTORY.md)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Get version
id: version
run: echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: Notify on Slack
uses: BeOpinion/slack-message-release-action@v1.3.1
with:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.changelog.outputs.changelog }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
Github Actions does not allow to install dependencies automatically when the action is loaded.
One way to fix this issue would be to version the node_modules
folder.
Another way would be to build the action into one single script also containing all its dependencies.
Here, we have chosen the second way. To do that, we use Vercel NCC tool.
So to build and release a new version:
- Build the Github Action (after installing ncc)
$ ncc build index.js -o dist
- Update
HISTORY.md
andpackage.json
version. - Commit them.
$ git add .
$ git commit -m "X.X.X release notes"
- Create a new tag for this version.
$ git tag -a "vX.X.X" -m "vX.X.X"
- Push the newly created commit and tag.
$ git push && git push --tags