Single Slack notification
mattBrzezinski opened this issue · comments
Hi,
I was wondering if it's possible to have a single Slack notification for a failure of a GH Action. I'm currently trying to setup some nightly CI testing. I'm testing on multiple platforms, while using this app is great if a failure occurs I'll get a message for each platform. Below's an example of what this action looks like:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- 1
os:
- ubuntu-latest
- macOS-latest
arch:
- x64
include:
- os: ubuntu-latest
version: 1.0.5
arch: x64
- os: ubuntu-latest
version: 1.3
arch: x64
- os: ubuntu-latest
version: nightly
arch: x64
steps:
...other steps...
- name: Notify slack fail
if: failure()
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: nightly-dev
status: FAILED
color: danger
Would also like to configure this to only send notifications depending on the environment which its running in. We are trying to set this up for various projects in the Julia language ecosystem. One issue we've also come across is building our packages nightly across various environments. We want to test on the nightly build of the language, however do not want e-mails to be sent.
It would be nice to do something like:
steps:
...other steps...
- name: Notify slack fail
if: failure() && version in [1.0.5, 1.3, 1]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: nightly-dev
status: FAILED
color: danger
As for only sending one notification, even having the option to send once and updating that message might be the easiest way? Any thoughts on this, definitely willing to contribute to this, might just need some guidance on how to setting up an environment, testing and practices.
Hi @mattBrzezinski I would recommend placing your failure notification in a separate job altogether, and then only run the job if a failure has happened:
jobs:
test:
# ...
report_failture:
name: Report Failure
needs: test
if: failure()
I'm not sure you can only report on certain matrix values with this mechanism. I'm also not sure whether this works altogether, but I think we're at the mercy of the Actions configuration and runtime at this point.
Good luck!
@mattBrzezinski were you able to successfully limit failures to one notification by moving notify slack fail
to its own job and needs
each of your test jobs?
@mattBrzezinski were you able to successfully limit failures to one notification by moving
notify slack fail
to its own job andneeds
each of your test jobs?
Yes! Here is an example of what we've deployed to all our repos.
Did something similar to matt here.