Continue a GitHub Actions workflow if a step errors

Back to index
Date: 2021-05-23
Category: githubActions


If a step in a GitHub Actions workflow step fails (ie. returns an exit code that's not zero), the entire workflow run will abort and report as failed.

In some situations, it may be impossible to avoid a step returning a non-zero exit code. This can be dealt with using the continue-on-error parameter for a step.

- name: Git commit and push
  run: |
    git config user.email 'actions@github.com'
    git config user.name 'github-actions'
    git add README.md
    git commit -m 'Update README.md'
    git push origin HEAD:${{ github.ref }}
  continue-on-error: true

In this example, the workflow will complete as normal, even if Git complains that there is nothing to commit and that the working tree clean, like it would if nothing had been changed.