-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
workflow level env. is unrecognised on job level's 'if'-expression when calling reusable workflow #1661
Comments
Hi @arauchberger, |
Thanks for the report @arauchberger! If it is helpful, we publish a list of contexts and what yaml fields they are available in on the GitHub Docs Website. Currently, we don't support this feature, but I've added the appropriate labels so we may consider it in the future. |
thanks for the feedback and the hint to the Context-Documentation. If i read it right the following should work instead of what i tried, since i can use the context 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' }}
# this should work ?
if: ${{ github.event.inputs.test_skip == 'false' }}
uses: ./.github/workflows/ay_test-workflow2.yml
with:
teststatus: true thanks in advance for conformation |
i just gave it a try - this works as expected now - that's a workaround i can live with. even though i do not really understand the reason for not having the workflow-level env context availably everywhere in the workflow. many thanks for your response. ps: should i close this issue now, or keep it open as a "feature-request"? |
Hi @arauchberger, Let's keep it open as a feature request 😊 |
i just found out that this does not work as expected! |
Thanks for the update, We will try to reproduce it to figure out what is going on. |
Hi @arauchberger, Please correct me if I did not understand this correctly, you expected on push to propagate inputs. But push does not allow inputs. Inputs are reserved for But please, correct me if I did not understand this properly. |
Hi @nikola-jokic, well, i did not really expect to propagate inputs on on on i don't see a way how to get this working. global env's are not available on i'm thankful for any help. maybe i do follow a totally wrong approach? |
Thanks for your quick response! Maybe, you can use this inside your if condition to accomplish that: Does this seem ok, @arauchberger? |
thanks @nikola-jokic for your support/help, this finally works: since is use this expression on multiple steps/jobs in my workflow it still would make sense that workflow-level env's can be used everywhere in the workflow. thanks |
Of course @arauchberger, I just wanted to provide a quick solution to your problem, so you can continue your work before the official fix is released. |
I'm seeing the same problem with For example, this does not work: name: Rust
on:
push:
branches: [main]
pull_request:
env:
CARGO_HACK_ARGS: --feature-powerset --exclude-features default --group-features base64,serde,arbitrary,hex
jobs:
publish-dry-run:
if: startsWith(github.head_ref, 'release/')
strategy:
matrix:
sys:
- os: ubuntu-latest
target: wasm32-unknown-unknown
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
uses: stellar/actions/.github/workflows/rust-publish-dry-run.yml@main
with:
runs-on: ${{ matrix.sys.os }}
target: ${{ matrix.sys.target }}
cargo-hack-feature-options: ${{ env.CARGO_HACK_ARGS }} # 👈 Does not work |
Not sure if the "hack" would do for you, but it's working for my situation right now. Basically, I set a workflow.env variable (JSON string in this situation), then I have the first job solely take those variables and turn them into outputs that all the other jobs can injest using the "needs" context. ` jobs: test_varaibles: |
any update on this issue ? |
Same problem here
fails |
Seeing this with inputs in a reusable workflow.
The errors seem to directly contradict the docs. Snippet below: on:
workflow_call:
inputs:
environment:
required: true
type: string
name: Publish Result
jobs:
publish-metrics:
runs-on: ubuntu-latest
steps:
- name: Configure credentials for ${{ inputs.environment }}
... Results in: |
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? |
I'm having a similar issue. I can't get environment vars to the reusable workflow. I have this workflow: name: Test
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- .github/workflows/test.yml
- .github/workflows/build.yml
pull_request:
branches: [ "main" ]
paths:
- .github/workflows/test.yml
- .github/workflows/build.yml
jobs:
build:
uses: ./.github/workflows/build.yml
with:
env: ${{ github.event_name != 'pull_request' && 'dev' || null }}
some-var: ${{ vars.TESTVAR }}
secrets:
some-secret: ${{ secrets.TESTSECRET }} and this reusable workflow: name: Test Build
on:
workflow_call:
inputs:
some-var:
required: false
type: string
env:
required: false
type: string
secrets:
some-secret:
description: 'Some secret'
required: false
jobs:
build:
runs-on: ubuntu-latest
name: Test for env ${{ inputs.env }} with some-var ${{ inputs.some-var }}
environment:
name: ${{ inputs.env }}
env:
TESTVARENV: ${{ inputs.some-var || 'some-var was empty' }}
TESTSECRETENV: ${{ secrets.some-secret || 'some-secret was empty' }}
steps:
- name: Test
run: |
echo $TESTVARENV
echo $TESTSECRETENV
echo Secret: ${{ secrets.some-secret }} inputs.some-var: ${{ inputs.some-var }}
echo Var direct access: ${{ vars.TESTVAR }} secret direct access: ${{ secrets.TESTSECRET }}
set The "dev" environment is set up like this: I get this output from the test stage:
That means the secret works and it gets send over to the reusable workflow successfully, but the vars is empty. According to: jobs.<job_id>.with.<with_id> | github, needs, strategy, matrix, inputs, vars The "vars" should be available in this case. After setting a repository variable it works with the wrong variable. Not using the environment one. I assume it doesn't have access to the environment yet when evaluating the "with" statements, while on the otherhand it seems to have access when using the secrets. |
following, as I have same issue. |
+1 |
* hotfix: fix trtllm CI build on release * fix: test release. * fix: test release. * fix: test release. env not recognized actions/runner#1661 * fix: test release. Works.
* hotfix: fix trtllm CI build on release * fix: test release. * fix: test release. * fix: test release. env not recognized actions/runner#1661 * fix: test release. Works.
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:
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 text was updated successfully, but these errors were encountered: