I have a workflow that constists of 3 jobs - "Start self-hosted EC2 runner", "Run Integration Tests" and "Stop self-hosted EC2 runner". A Github Action that I used as a source for my implementation can be found at this link. In practice when Tests are failing and its job looks "red", workflow still looks "green" and I need to fix that (= make it look "red"). However, it is mandatory that "Stop self-hosted EC2 runner" job must execute even if "Run Integration test" job fails, so I can not fail the workflow from within "Run Integration Tests" job.

I suspect I can add yet another job dependent on all three, which then checks the status of all the Jobs and fail the workflow. How can I do that or otherwise make workflow "red" while always executing "Start.." and "Stop..." jobs regardless of tests success or failure?
The cause of workflow not failing is that 2nd job has to have continue-on-error: true attribute.
I ended up adding another job at the end like so:
// Last job:
  fail-on-job2:
    # Without this step workflow remains "green" if job2 does fail.
    name: Job2 Status -> Workflow Status
    needs:
      - job1
      - job2
      - job3
    runs-on: ubuntu-latest
    if: always()
    steps:
      - uses: technote-space/workflow-conclusion-action@v2
      - name: Check Job Status status and fail if they are red
        if: env.WORKFLOW_CONCLUSION == 'failure'
        run: exit 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With