workflow level env. is unrecognised on job level's 'if'-expression when calling reusable workflow
See original GitHub issuethe 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'
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:21 (5 by maintainers)
Top Results From Across the Web
Environment variable not recognized when used for ...
The solution is to pass the environment variables as the output of a job, like here.
Read more >Reusable workflows in Github Actions - YouTube
Source code: https://github.com/HoussemDellai/github-actions-course Follow me on Twitter for more content: ...
Read more >Avoid Duplication! GitHub Actions Reusable Workflows
If Composite Actions can be thought of as Templates, Reusable Workflows is on another new level. Right, let's see how to create a...
Read more >Musings on GitHub Actions Reusable Workflows
env variables set in the calling workflow are not accessible to the called workflow. The only parameter types that are supported are string...
Read more >GitHub Actions
Action — An action is a reusable unit of code that performs a specific task within a workflow. Actions can be predefined and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m seeing the same problem with
env
at the workflow level and reusable workflows.For example, this does not work:
Hey!
Using env variables in reusable workflows still unavailable. Using like this (see code below) still throws an error.
Is there any plans or deadlines to fix this?