What is usage difference between: job.status == 'success' and if :success() ?

Hi,

what is possible usage difference between:

if: job.status == 'success'

and

if: success()

Thanks.

job.status is a context of the current job. Possible values are success, failure, or cancelled. job.status could be used not only in if conditional but also in other places, such as using it as an input variable value of an action.  

- name: Dump job context
        env:
          JOB_STATUS: ${{ job.status }}
        run: echo "$JOB_STATUS"

success() is a check function which could be used as an expression in if conditionals.

When they are used in jobs.<job_id>.steps.if  conditional, there is no difference between them. You could choose any one you like.  

success() could be used in jobs.<job_id>.if , but job.status  could not.

1 Like

Many thanks for explanation.