Skip to content

Run/Stop If Fails | Succeeded

Check

run even if a previous step fails

YAML
steps:
- name: Build App
  run: ./build.sh

- name: Archive Test Results
  if: always()
  uses: actions/upload-artifact@v1
  with:
    name: test-results
    path: app/build

or as jobs:

YAML
jobs:
  job1:
  job2:
    needs: job1
  job3:
    if: always()
    needs: [job1, job2]

If you don't want the function to run when you manually cancel a job, you can instead put:

YAML
if: success() || failure()

or

YAML
if: '!cancelled()'

run a function ONLY when something has failed

YAML
if: failure()

if a status check function is not used in if, like

YAML
if: true

the result will (perhaps confusingly) behave like

YAML
if: success() && true

Expressions - GitHub Docs

if: success() is always implied unless you specify always() or failure() - even if you set e.g. if: true

Use success() || failure() instead of always()