I’m planning on writing a workflow which executes the unit, integration and E2E tests as separate steps. As part of this, I would like to change what artifacts are uploaded for a failed test run based on which testing step failed. Is it possible for a step to know which step failed? E.g. unit tests should upload just a summary of the unit tests, whilst the E2E tests may include screenshots of the failed tests?
Hi @jeffersonbledsoe ,
You could use steps.<step id>.outcome to get the step result. And you could use if conditional in the upload artifacts step, add always() in addition to let the step to run even if previous step failed.
if: always() && steps.step2.outcome == ‘failure’
jobs: build: runs-on: ubuntu-latest steps: - name: step1 run: echo "hello 1" id: step1 continue-on-error: true - name: step2 run: | echo "hello 2" fff id: step2 #continue-on-error: true - name: step3 if: always() && steps.step2.outcome == 'failure' run: echo "hello 3" id: step3
@yanjingzhu Works great, thanks for the help!