Skip to content

Conditionally run a Job based on the output of another Job #25941

Answered by weide-zhou
itsjxck asked this question in Actions
Discussion options

You must be logged in to vote

Hi @itsjxck,

Glad to see you in Github Community Forum!

This is due to you omit ${{}} for the step output value in job run-check, the job output value is not true in this case.

Fixed as below:

jobs:
  run-check:
    runs-on: ubuntu-latest
    outputs:
      approved: ${{ steps.pre-val.outputs.approved }}  # add ${{ }} for the step output
    steps:
      - name: PR Approval Status
        id: pre-val
        run: |
           echo "::set-output name=approved::true"
  deploy:
    needs: [run-check]
    runs-on: ubuntu-latest
    if: needs.run-check.outputs.approved == 'true'

Thanks

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants