title: Conditional "needs" in GitHub Action?
body: <p>I have a (simplified) GitHub workflow that looks like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>jobs:
    build:
      runs-on: ubuntu-latest
      steps:
        - run: echo &quot;build&quot;
  
    test:
      runs-on: ubuntu-latest
      needs: build
  
      steps:
        - run: echo &quot;build&quot;
  
    deploy:
      runs-on: ubuntu-latest
      needs: [build, test]
  
      steps:
        - run: echo &quot;deploy&quot;
  </code></pre>
  <p>Now, I'd like to make it so that the <code>deploy</code> step only needs the <code>tests</code> step if the branch is <code>main</code>.</p>
  <p>Is that possible?</p>
  <p>Essentially I'd love to do something like this:</p>
  <pre class="lang-yaml prettyprint-override"><code>jobs:
    build:
      runs-on: ubuntu-latest
      steps:
        - run: echo &quot;build&quot;
  
    test:
      runs-on: ubuntu-latest
      needs: build
  
      steps:
        - run: echo &quot;build&quot;
  
    deploy:
      runs-on: ubuntu-latest
      needs: contains(branch, &quot;master&quot;) ? [build, test] : [build] #notice this line
  
      steps:
        - run: echo &quot;deploy&quot;
  </code></pre>