Skip to content

workflow level env. is unrecognised on job level's 'if'-expression when calling reusable workflow #1661

Open
@arauchberger

Description

the idea is to have a workflow_dispatch input to choose wether or not to execute tests after the build part is done.

Describe the bug
environment variable defined on workflow level is not available for if-condition on job level - in case the job is calling another "reusable" workflow.
everything is fine within a regular job and it's steps.

To Reproduce
Example:

name: ay_test_condition

on:
  workflow_dispatch:
    inputs:
      build_skip:
        description: 'skip maven and chart builder'
        required: true
        default: false
        type: boolean  
      test_skip:
        description: 'skip product integration tests'
        required: true
        default: false
        type: boolean    

# workflow level env
env:
  BUILD_SKIP: ${{ github.event.inputs.build_skip == 'true' }}
  TEST_SKIP: ${{ github.event.inputs.test_skip == 'true' }} 

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Display build environment
        id: displayBuildEnv
        shell: bash
        run: |
          echo "build_skip: ${{ github.event.inputs.build_skip }}";
          echo "env.BUILD_SKIP: ${{ env.BUILD_SKIP }}";
          echo "test_skip : ${{ github.event.inputs.test_skip }}";
          echo "env.TEST_SKIP: ${{ env.TEST_SKIP }}";
      
      - name: build something
# works fine here (at workflow.job.step level)      
        if: ${{ env.BUILD_SKIP == 'false' }}
        run: |
          echo "Building something"   

  test:
    needs: build
# does not work here (at workflow.job-workflow_caller)    
    if: ${{ env.TEST_SKIP == 'false' }}
    uses: ./.github/workflows/ay_test-workflow2.yml
    with:
      teststatus: true   

Expected behavior
the env should be available everywhere, since it's declared on workflow level.

Runner Version and Platform

Current runner version: '2.287.1'
Operating System
Ubuntu
20.04.3
LTS
Virtual Environment
Environment: ubuntu-20.04
Version: 20220131.1
Virtual Environment Provisioner
1.0.0.0-main-20220201-1

What's not working?

Errormessage:

The workflow is not valid. .github/workflows/ay_test_condition.yml (Line: 45, Col: 9): Unrecognized named-value: 'env'. Located at position 1 within expression: env.TEST_SKIP == 'false'

Metadata

Assignees

Labels

Actions FeatureFeature requires both runner, pipelines service and launch changescontext

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions