actions / actions/runner

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

Open
#1,661 22 comments 18 reactions 1 assignee View on GitHub

@nikola-jokic is already working on this.

Since Feb 11, 2022.

Actions Feature context
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

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'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.