Not require dependent Job to run

I have the following:
job3 depends on job1 & job2. But job2 can be skipped based on an expression.

How do I:

  • run job3 after job2
  • run job3 even if job2 is skipped?
  • do not run job3 if job2 fails
    if: ${{env.job2Enabled}}
    if: ${{ success() }}
    needs: [job1, job2]

You could try this:

  if: env.job2Enabled && success()

You have a syntax error in your workflow or does github actions allow it now?

You cannot use the env context in job if, which make me to believe you are using nektos/act.

See Issue: GitHub Actions says workflow is not valid because of `${{ !env.ACT }}` · Issue #720 · nektos/act · GitHub

For github some infomation ( this won’t apply to act, it acts differently ) about the status functions

Add this condition to job3 to run it even when dependent jobs are skipped, also not applies to act
if: "!failure() && !cancelled()"

I suggest to replace act with GitHub - ChristopherHX/runner.server: An unofficial Console Client and Server for GitHub Action Runners it isn’t as far away from github as act.

1 Like