actions/runner
issue 998 is an example of such a need for dynamic input, but was closed.
You have different approaches illustrated here to emulate that feature, but you can also try, using "GitHub Actions: Input types for manual workflows":
- adding a config file to your repository
- read values from that files depending on your choice.
The config file: dynamic_options.json
:
{
"Color": ["Green", "Blue", "Red"],
"Fruit": ["Apple", "Orange"]
}
And your workflow script:
name: Dynamic Dropdown Workflow
on:
workflow_dispatch:
inputs:
list_1:
typoe: choice
description: 'Select options:'
required: true
default: 'Color'
options:
- Color
- Fruit
list_2:
description: 'Select dynamic options:'
required: true
default: ''
jobs:
dynamic-dropdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install jq
- name: Retrieve dynamic options
id: get_dynamic_options
run: |
IFS=',' read -ra INPUT_OPTIONS <<< "${{ github.event.inputs.list_1 }}"
DYNAMIC_OPTIONS=""
for option in "${INPUT_OPTIONS[@]}"; do
OPTION_VALUES=$(jq ".$option | join(\",\")" dynamic_options.json --raw-output)
if [ -n "$DYNAMIC_OPTIONS" ] && [ -n "$OPTION_VALUES" ]; then
DYNAMIC_OPTIONS+=","
fi
DYNAMIC_OPTIONS+="$OPTION_VALUES"
done
echo "DYNAMIC_OPTIONS=$DYNAMIC_OPTIONS" >> $GITHUB_ENV
- name: Use dynamic options
run: |
echo "Selected options from List 1: ${{ github.event.inputs.list_1 }}"
echo "Selected options from List 2: $DYNAMIC_OPTIONS"
# Continue with your workflow steps using the dynamic options