I'm new to Github Actions, and I'm trying to find a way to achieve the following functionality: Whenever a step fails, it will show that it failed (will provide correct feedback) but will still continue to other steps.
At the moment, failure causes the step to stop:
I've seen the most popular suggestion is to use continue-on-error, but that seems to make the step's conclusion 'Success', and will not show it failed unless you go into the logs.
In the screenshot above, the "Secrets" step failed, and yet it appears to be successful unless entering the logs.
When reading this thread, I came to suspect this feature might not exist yet in GH actions.
I've also tried using conditionals for each step, and/or for the job.
For example, I've tried:
if: ${{ success() }} || ${{ failure() }}
- this simply did not provide the needed functionality, the step failed and the next step did not start.
if: succeeded() || failed()
- took this syntax from the Github community thread above, but it generated a syntax error (which makes sense, since it isn't compatible with the syntax specified here).
To conclude, I'm looking for a way to make steps that fail indicate they failed, and still make the workflow continue to the next step.
Thank you!
Conclusion. The best platform for you all depends on your specific needs. If you host your code somewhere other than GitHub.com or GitHub Enterprise, you will be better off using Travis CI. However, if you host your code on GitHub.com or GitHub Enterprise, the choice can be a little more difficult.
GitHub actions have some good default security measures built in, but you can do more to protect yourself. GitHub Actions 1 are programs designed to run inside of workflows 2, triggered by specific events inside a GitHub repository.
Re-running all the jobs in a workflowIn the left sidebar, click the workflow you want to see. From the list of workflow runs, click the name of the run to see the workflow run summary. In the upper-right corner of the workflow, use the Re-run jobs drop-down menu, and select Re-run all jobs.
I wanted to have a GitHub Action step run that might fail, but if it failed the rest of the steps should still execute and the overall run should be treated as a success. Skip to primary navigation Skip to content Skip to footer An independent mind... Portfolio Posts Categories Tags About Toggle searchToggle menu Francis T. O'Donovan
GitHub Actions Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a completely customized workflow.
I described that solution in the original question, but this doesn't work in my case, because with continue-on-error, a failed task will still cause the overall build to pass. And i still wanted failed builds to be marked as failed, while still running this task regardless of the previous tasks.
In other words, one can simply use: if: always (). Note that this has the unwanted side effect that you can no longer manually cancel your workflow: docs.github.com/en/actions/managing-workflow-runs/… Contrary to if: always (), if: success () || failure () keeps the ability to cancel builds while still achieving the OPs goal.
To my surprise, and thanks to @smac89 for suggesting it - adding if: always()
seems to do the trick.
I'm still wondering why if: ${{ success() }} || ${{ failure() }}
failed, but the solution seems to work for the moment.
Thank you for the help!
The continue-on-error
is indeed popular, and part of the reason is perhaps that you can set it for each step, or for the whole job. I’m not sure you are aware of this, and this solution was the answer I was looking for.
So this will continue all steps, if either fails:
Job:
MyRun:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Step One
run: curl --fail -o dates.csv https://doesnotexist.com/dates.csv
- name: Step Two
run: date >> dates.csv
And this will only continue if “Step One” fails, it will break and stop if e.g. “Step Two” fails:
Job:
MyRun:
runs-on: ubuntu-latest
steps:
- name: Step One
run: curl --fail -o dates.csv https://doesnotexist.com/dates.csv
continue-on-error: true
- name: Step Two
run: date >> dates.csv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With