Hopefully reusable workflow agrees to support ${{inputs. XXX}} expression parameter passing
See original GitHub issueDescribe the enhancement I wanted to pass the parameters of the workflow_dispatch input in a reusable workflow, and with ${{inputs.username}} expression, the value could not be read and without an error message.
But if using ${{github.event.inputs.username}} it works fine, I don’t know why. The official documentation does not detail the difference between the two and which to use in reusable workflows
Code Snippet
name: Caller
on:
workflow_dispatch:
inputs:
username:
type: string
description: 'username'
required: false
default: 'john-doe'
jobs:
Test-1:
uses: ./.github/workflows/test_1.yml
with:
username: ${{ inputs.username }} #${{ github.event.inputs.username }}
secrets: inherit
name: Executor
on:
push:
workflow_call:
inputs:
username:
type: string
description: 'A username passed from the caller workflow'
default: 'john-doe'
required: false
jobs:
Test-1:
runs-on: ubuntu-latest
steps:
- name: Print the input name to STDOUT
run: echo The username is ${{ inputs.username }}
Additional information Add any other context about the feature here.
NOTE: if the feature request has been agreed upon then the assignee will create an ADR. See docs/adrs/README.md
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Passing env variable inputs to a reusable workflow
Any environment variables set in an env context defined at the workflow level in the caller workflow are not propagated to the called...
Read more >GitHub Actions Reusable Workflows FULL TUTORIAL with ...
You can now reuse entire GitHub Actions workflows as if they were a ... Actions Reusable Workflows make workflows easier to maintain and ......
Read more >Untitled
Hopefully reusable workflow agrees to support ${{inputs. XXX ... https://benediktbergmann.eu/2020/05/01/pcf-prevent-saving-the-form-when-input-is-invalid/ ...
Read more >Daml SDK Documentation - DAML Docs
The Daml code defines the data and workflow of the application. ... The prop will be passed down from the MainView component, reusing...
Read more >Activiti User Guide
The passed parameters can be literal values or expressions that are resolved ... It remains in that state until a user decides to...
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 Free
Top 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
Same here ☝️
I’m filing a bug report with our GitHub Enterprise Cloud support. Here are some more details and examples for anyone interested.
Now that inputs have been unified across manual and reusable workflows, we’ve moved to using the
inputs
context across all workflow files. However, as of the last week or so, we’ve noticed a transparent change where theinputs
context is broken within reusable workflows when those values are computed from inputs to the dispatched workflow. In other words, the reusable workflow’sinputs
context is trampled and/or muddied by the dispatched workflow’sinputs
context, depending on how inputs are passed.Example 1
In this example, we’re just setting up the workflow files.
Running this workflow, whether a value is set for
gitRef
or not, results in the following expected output:Example 2
The reusable workflow remains the same, but we’ve modified how it’s being called (with the
inputs
context):results in the following when
example
is passed as thegitRef
to the dispatchable workflow:Example 3
The previous example looks like a possible name clash, so let’s modify our dispatchable workflow even further to avoid a possible clash:
results in the following when
example
is passed as thecheckoutRef
to the dispatchable workflow:Still not what we’re expecting as output within the reusable
Tests
workflow. I’d expect:It appears that
inputs.checkoutRef
was not properly evaluated when setting the value forgitRef
and somehow both fields ended up getting passed to the reusable workflow.Example 4
Now, let’s switch from using the
inputs
context to usinggithub.event.inputs
within the dispatchable workflow. Again, nothing has changed in the reusableTests
workflow since the beginning.results in the following when
example
is passed as thecheckoutRef
to the dispatchable workflow:this finally gives us the correct behavior in
gitRef
, but again, still doesn’t quite match theinputs
context I’d expect within the reusableTests
workflow, given that we’re providing inputs explicitly with thewith
keyword. Expected output:Example 5
In this example, we’re unifying the names of the inputs once again.
results in the following when
example
is passed as thegitRef
to the dispatchable workflow:and the following when nothing is passed as the
gitRef
to the dispatchable workflow:This is close to the correct behavior. It allows computation (namely, default / fallback values) and the inputs context is correct within the reusable
Tests
workflow.However, it’s only not “muddied” because the input names match. Any additional inputs added to the dispatchable workflow end up in the
inputs
context for the reusable workflow even though they’re not explicitly passed (muddying). If the reusable workflow has an input name that matches an input name from the dispatchable workflow, we end up with an empty / nullish value in theinputs
context within the reusable workflow (trampling).Requested Change
The
inputs
context is scoped to the appropriate workflow and inputs into reusable workflows can be computed from inputs into dispatched workflows.We have noticed this regression and waiting for the fix to be rolled out. Apologies for the inconvenience 😦
cc @genieCS