Update: The steps context now contains detail about the execution of each step by default. Using the outcome property of each step we can check the result of its execution.
name: CI
on: [pull_request]
jobs:
myjob:
runs-on: ubuntu-latest
steps:
- name: Step 1
id: hello
run: <any>
continue-on-error: true
- name: Step 2
id: world
run: <any>
continue-on-error: true
- name: Check on failures
if: steps.hello.outcome != 'success' || steps.world.outcome != 'success'
run: exit 1
Original answer
Looking at the documentation for the steps context, it doesn't look like it contains any information about the step other than outputs. These must be explicitly defined by steps. That is why the steps context is empty {}.
https://help.github.com/en/articles/contexts-and-expression-syntax-for-github-actions#steps-context
Unfortunately, as far as I can tell, there is no default status for a step that can be accessed. The solution involves manually defining a status output variable from each step.
name: CI
on: [pull_request]
jobs:
myjob:
runs-on: ubuntu-latest
steps:
- name: Step 1
id: hello
run: echo ::set-output name=status::failure
continue-on-error: true
- name: Step 2
id: world
run: echo ::set-output name=status::success
continue-on-error: true
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Check on failures
if: steps.hello.outputs.status == 'failure' || steps.world.outputs.status == 'failure'
run: exit 1
This creates the following context output and the job fails.
{
"hello": {
"outputs": {
"status": "failure"
}
},
"world": {
"outputs": {
"status": "success"
}
}
}
https://help.github.com/en/articles/metadata-syntax-for-github-actions#outputs
https://help.github.com/en/articles/development-tools-for-github-actions#set-an-output-parameter-set-output
- name: Check on failures run: ${{ toJson(steps) }} ${{ toJson(job.steps) }}then I will get{} null- Maxim