Skip to content

Job-level if condition is not evaluated correctly #1996

@roryabraham

Description

@roryabraham

Describe the bug
I've got a workflow and an abbreviated version of it might look something like this:

name: Process new code merged to main

on:
  push:
    branches: [main]
    
jobs:
  chooseDeployActions:
    runs-on: ubuntu-latest
    outputs:
      SHOULD_DEPLOY: ${{ steps.shouldDeploy.outputs.SHOULD_DEPLOY }}
    steps:
      - id: shouldDeploy
        run: echo "::set-output name=SHOULD_DEPLOY::true"
        
  debugChooseDeployActions:
    runs-on: ubuntu-latest
    needs: chooseDeployActions
    steps:
      - if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }}
        run: echo 'This proves that the expected output is true and this is a GitHub bug'

      - if: ${{ !fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }}
        run: echo 'This is weird'

      - run: echo '${{ needs.chooseDeployActions.outputs.SHOULD_DEPLOY }}'
      
  createNewVersion:
    needs: chooseDeployActions
    if: ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }}
    uses: Expensify/App/.github/workflows/createNewVersion.yml@main
    secrets: inherit

And when running the action, I'm seeing that the first step of the debugChooseDeployActions job is running, which means that ${{ fromJSON(needs.chooseDeployActions.outputs.SHOULD_DEPLOY) }} evaluates to true. However, that same condition is used for the job-level if condition of the createNewVersion job, and that job is being skipped.

To Reproduce
It's unclear – the proof is here, but I'm unable to reproduce this in another repo with a similar workflow.

Expected behavior
The job-level if condition should be evaluated the same as the step-level if condition.

In my above example, the createNewVersion job should run.

Runner Version and Platform

Using GitHub-hosted runners, so version is presumably latest. Jobs in question are using:

  • ubuntu-latest
  • macos-latest

What's not working?

Debug logs and the job dependency graph can be seen here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions