How to get job.status into shell script?

It should be really basic stuff but I couldn’t figure it out…
There is job.status context, and I want to use it in my shell script (in order to set a color for Slack notification). How can I get this job.status into script?

You need to provide it to the step in some way. Exactly how depends on how your script wants to consume that data. You could put it on the command line:

  - run: ./ ${{ job.status }}

Or into the environment:

  - run: ./
      STATUS: ${{ job.status }}
1 Like

Many thanks!
In fact, I asked the wrong question. I’m using Github action for Slack notification and I’d like to use the job status for setting Slack notification color. I don’t like to idea using separate steps for each job status, i.e. for success(), failure(), and so on.
I’m trying to use an expression for setting color param; without success so far.

      color: ${{ env.STATUS }} == 'success' && 'good' || 'bad'

Tried “color: failure() && ‘good’ || ‘bad’” and other variations - the same result.

I figured it out - as usually RTFM helps.
Thank you again.

color: ${{ job.status == ‘success’ && ‘good’ || ‘bad’ }}

1 Like