1
0
mirror of https://github.com/arduino/library-registry.git synced 2025-07-29 14:01:15 +03:00

Restrict failure handling job runs to specific job failure

GitHub Actions workflow jobs default to the `if: success()` configuration. In this configuration, the job only runs when
the result of its job dependencies was success. When configuring a job to run on a failure result with `if: failure()` it
is logical to assume that the behavior would be inverted: the job would run only when the result of its dependency job
was failure. It does this, but also runs when its dependency job was canceled due to a failure of its own dependency.

This behavior of GitHub Actions resulted in the failure handling jobs running when they were not intended to. That is
avoided by specifying the exact job whose failure they were intended to handle in the conditional. It is still necessary
to use failure() in the conditional, otherwise they retain the default success() configuration and never run on a failure.
This commit is contained in:
per1234
2021-04-27 22:16:52 -07:00
parent fd1da642b2
commit f6342960d1

View File

@ -256,7 +256,8 @@ jobs:
check-submissions-fail:
needs:
- check-submissions
if: failure() # This job will only run if the submission checks failed
# Only run if the check-submissions job failed
if: failure() && needs.check-submissions.result == 'failure'
runs-on: ubuntu-latest
steps:
@ -342,7 +343,8 @@ jobs:
merge-fail:
needs:
- merge
if: failure()
# Only run if the merge job failed
if: failure() && needs.merge.result == 'failure'
runs-on: ubuntu-latest
steps:
- name: Comment on merge failure