GitHub Action: Avoid "if: always()"
jrchamp opened this issue · comments
From https://docs.github.com/en/actions/learn-github-actions/expressions#always
If you want to run a job or step regardless of its success or failure, use the recommended alternative:
if: ${{ !cancelled() }}
In ncstate-delta/moodle-mod_zoom#531, I proposed change to our plugin's GitHub Action. It occurred to me that some of these changes might be beneficial to include in the example file gha.dist.yml
. Here are some of the benefits it may offer:
- Only run moodle-plugin-ci steps when the moodle-plugin-ci installs successfully
- Use
!cancelled()
instead ofalways()
as recommended by GitHub - If the job has been cancelled, mark the job as failed so that PR status checks cannot be bypassed
If you would prefer, I would be willing to open a PR. Mainly, I want to make sure I'm only suggesting desired/acceptable changes.
Hello @jrchamp, thanks, your proposal sounds good. I am not sure if sucessful installation of moodle-plugin-ci needs to be checked though, if it fails with non-zero exit status, it is supposed to stop at that installation step.
Thanks @kabalin! With both always()
and !cancelled()
, the steps do continue (because failure()
is true
). However, that may not be a problem, as each of the steps will also fail with a non-zero exit status. I'll create a PR with part 1 removed for review.