Hopefully an easy one. I need to trigger slacknotification for failed jobs triggered by a cron schedule in GitHub actions. The script forces a failure to test slacknotification functionality. No matter what I try, I can't seem to get the scheduled run to trigger. This script resides in the main branch so it should trigger scheduled jobs.
on:
push:
schedule:
- cron: '*/5 * * * *'
jobs:
test-fail:
runs-on: ubuntu-latest
steps:
- name: force fail
run: exit 1
test-skip:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: force fail
run: exit 1
slackNotification:
if: ${{ github.event_name == 'schedule' && (needs.test-fail.result == 'failure' || needs.test-skip.result == 'failure') }}
needs: [test-fail, test-skip]...
on slackNotification: if: ... line, notification will work if I use always() instead of github.event_name == 'schedule but that will trigger with CI push as well. I only want to trigger the action if schedule event fails. There are a bunch of these scattered across stackoverflow like this one, but they don't quite cover this exact scenario.
Am I close?