I want to create a dropdown list for my GitHub Action Input parameter. This should help in selecting a value from the dropdown just like how the option is there to select the branches.
Asked
Active
Viewed 3.4k times
36
-
1This is no such feature in GitHub actions yet. – Mohammad Dohadwala Sep 23 '21 at 08:21
-
@MohammadDohadwala there is now. – airtonix Mar 09 '23 at 08:39
1 Answers
74
When using workflow_dispatch
, it's now possible to have choice
, boolean
and environment
inputs instead of only just strings. choice
is a dropdown, boolean
is a checkbox and environment
is like choice
but will auto-populate with all environments configured in your repos settings.
Here's an example workflow using the new types:
name: CI
on:
workflow_dispatch:
inputs:
environment:
type: environment
description: Select the environment
boolean:
type: boolean
description: True or False
choice:
type: choice
description: Make a choice
options:
- foo
- bar
- baz
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: greet
run: |
echo "environment is ${{ github.event.inputs.environment }} / ${{ inputs.environment }}"
echo "boolean is ${{ github.event.inputs.boolean }}" / ${{ inputs.boolean }}
echo "choice is ${{ github.event.inputs.choice }}" / ${{ inputs.choice }}
Note that inputs can now be accessed directly using the inputs
context, instead of using github.event.inputs
.

Jonas Lomholdt
- 1,215
- 14
- 23
-
1Perfect!! Thanks a lot :) Can I load/pass the parameters using the JSON file ? – vik_nag Nov 11 '21 at 04:23
-
1I'm actually unsure when variable substitution will happen in the workflows lifetime. So I'm not convinced that would work. But you should definitely give it a try! – Jonas Lomholdt Nov 11 '21 at 10:41
-
https://docs.github.com/en/actions/learn-github-actions/contexts#example-usage-of-the-inputs-context-in-a-manually-triggered-workflow do you know why github recommends using `inputs.inputname` and not `github.event.inputs.inputname`? Are they equivalent? – Jun 30 '22 at 15:10
-
@walnut_salami Yes they are equivalent. This is because they unified the way you access inputs so it's the same across workflows triggered manually using `workflow_dispatch` and workflows called by another workflow using `workflow_call`. See this blog post for reference: https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/ – Jonas Lomholdt Jul 01 '22 at 06:59
-
2What about populating the choice programmatically or another way to input in one of the steps? – Luis Mauricio Oct 25 '22 at 16:30
-
-
Is it somehow possible to have multiple values for a single option - an object maybe ? is this possible ? – Ceylan Mumun Kocabaş Mar 24 '23 at 09:33
-