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


what is possible usage difference between:

if: job.status == 'success'


if: success()


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
          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.