Emit when a step is on its "last attempt"
Closed this issue · 2 comments
We are using this action in our project and in the command script, we send a notification to slack on failure.
We want to differentiate an "intermediate step fail" vs "the last attempt failed".
I made an attempt to solve this #8 but I realized that you can't use setOutput
/exportVariable
in the same step (it is only available in the next step).
So, I figured a way out by using the filesystem and a variable for changing the filename (to use retry in multiple steps).
I don't think that the current PR is in a mergeable state but I wanted to take this opportunity to raise this issue with you.
Have you thought of this problem? Do you think there is a better way to solve this?
Happy to write code for it if we decide on an approach.
Thanks for the issue and PR. I'm hesitant about the PR because this feels more like an edge case as test and notification scripts are typically separate. If it were me, I would move the notification script into it's own command. This way when the last retry attempt fails, the retry action will fail and an on failure
notification can be sent that is different from the on success
notification (if any).
This is how I'm handling that same scenario elsewhere:
- name: Flaky tests
uses: nick-invision/retry@v1
id: flaky-tests
# this allows the job to continue but outputs the pre-continueOnError status for use later
continue-on-error: true
with:
timeout_minutes: 10
max_attempts: 5
command: npm run test:flaky
# phone home only if something fails as determined by pre-continueOnError status
# note the `outcome` output is used, not the `result` output
- if: ${{ needs.flaky-tests.outcome != 'success' }}
run: ./notify.sh # or whatever your slack command is