Make something both workflow_call and workflow_dispatch #39357
-
Select Topic AreaQuestion BodyI have a workflow in a repo using
In a separate 'launcher' repository, I invoke the repo workflow file in
In this way, I can launch repo.yml from the GitHub Actions UI in the launcher. Now, I want the original repo to also have a GitHub Actions UI button. Do I simply duplicate all the input parameters?
|
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 3 replies
-
Yes, exactly. There's no way to share the definitions between triggers. But as long as the inputs are the same the |
Beta Was this translation helpful? Give feedback.
-
Will be good to have a shared_inputs at-least between workflow_call and workflow_dispatch, for anyone who's working on resuable_workflow it'll be much easier to test independently without any duplication in code. |
Beta Was this translation helpful? Give feedback.
-
i have tested and if inputs are same in both workflow_call and workflow_dispatch it works. |
Beta Was this translation helpful? Give feedback.
-
IMO, |
Beta Was this translation helpful? Give feedback.
-
Because there might be instances where inputs might not all be shared, ideal would be a:
|
Beta Was this translation helpful? Give feedback.
-
Hello, I found this in googling. Yes the answer is you have to duplicate the inputs. I wanted to add that for those consuming the workflow_call and workflow_dispatch that you'll likely want to then assign the inputs to an environment variable to ensure that other triggers like, on push or cron will also apply the defaults uniformly. Use the inputs context in combination with creating an env variable that evaluates using a ternary operation that applies the desired "default" to the environment variable in case of having the action execute outside of workflow_call and workflow_dispatch. As the examples show using
Ie: name: repo workflow
on:
schedule:
- cron: '0 0 * * *' # 12:00am UTC
workflow_dispatch:
inputs:
foo:
type: string
default: 'bar'
workflow_call:
inputs:
foo:
type: string
default: 'bar'
# make it so the default for on.schedule we still have a default of 'bar' in `{{ env.foo }}`
env:
foo: ${{ inputs.foo == null && 'bar' || inputs.foo }}
jobs:
repo-job:
runs-on: ubuntu-latest
steps:
- name: print param
run: echo "${{ env.foo }}" |
Beta Was this translation helpful? Give feedback.
-
Is it possible to avoid duplication of inputs in workflow_call and workflow_dispatch? Can we use shared_inputs between workflow_call and workflow_dispatch ? |
Beta Was this translation helpful? Give feedback.
-
I agree would be useful to share inputs, as input list can be quite long... |
Beta Was this translation helpful? Give feedback.
Yes, exactly. There's no way to share the definitions between triggers. But as long as the inputs are the same the
inputs
context should work either way. 😅