Trigger job based on if condition is met

hi,

I have two jobs like build: and deploy:
deploy: must be trigger based on env variable at the top (global level)

env:
    DEPLOY : 'false'

job:1 

job2: 
     if: env.DEPLOY == 'true' 

then only job2 has to execute, please provide me the solution to achieve this

Global env is not available at job level, it’s only available at step level. See: How to use env context?

So you can do something like

name: workflow

on:
  push:
    branches: 
    - master

env:
  DEPLOY: "false"

jobs:
  job1:
    runs-on: ubuntu-latest
    steps:
    - run: echo ${{ env.DEPLOY }}
      if: env.DEPLOY != 'true'
  job2:
    runs-on: ubuntu-latest
    steps:
    - run: echo ${{ env.DEPLOY }}
      if: env.DEPLOY == 'true'

Another workaround is described in How to set and access a Workflow variable?

when can we expect direct solution at job level rather each step in the job

Hi @chaitanya-bojja-by,

You can add a job to get top level env, set it as ouput and use it in the latter job level if expression, which is decribed in How to set and access a Workflow variable?

Code sample as below:

env:
  Deploy: 'false'

jobs:
  prejob:
    runs-on: ubuntu-latest
    outputs:
      envvalue: ${{ steps.setvar.outputs.envvar }}
    steps:
      - name: set value
        id: setvar
        run: |
          echo "::set-output name=envvar::$Deploy"  # get top level env and set it as output
  envcheck:
    needs: [prejob]
    if: ${{needs.prejob.outputs.envvalue=='false'}}  # check env value in job level expression now.
    runs-on: [ubuntu-latest]
    steps:

Github could support env at job level, sorry there is no time line to share yet.
It’s recommended to raise a feedback ticket in below link where github product manager will help to check and answer, and it will promote the improvement.
https://support.github.com/contact/feedback?contact[category]=actions

Thanks