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.
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
.