Where can I find all available input types for workflow_dispatch? There is only example.
yaml - How to define inputs in a `push` trigger in Github Actions? - Stack Overflow
Options lists for `type: choice` inputs in `gh workflow run`
How to provide multiple inputs for a manually triggered (workflow_dispatch) workflow in github actions? - Stack Overflow
Support "multi-choice" input type for manual workflows
Videos
So workflow_dispatch events actually support 3 input types; choice, environment, boolean.
I don't think you'll be able to pass inputs for matrix tasks that expect a list of values though (you can definitely do it for single values
If there are only several inputs you might be able to use multiple booleans and conditionally run jobs or steps. Not as clean clean but will do the job.
on:
workflow_dispatch:
inputs:
repo_1:
type: boolean
default: false
description: Use Repo 1?
repo_2:
type: boolean
default: false
description: Use Repo 2?
jobs:
repo-1-job:
name: Repo 1 Job
runs-on: ubuntu-latest
if: github.event.inputs.repo_1 == 'true'
steps:
- run: echo "some repo 1 job"
repo-2-job:
name: Repo 2 Job
runs-on: ubuntu-latest
if: github.event.inputs.repo_2 == 'true'
steps:
- run: echo "some repo 2 job"
I'm following the idea of the example from the fromJSON documentation that sets a JSON matrix in one job, and passes it to the next job using an output.
The first job collects the true and false values from the inputs and creates a JSON object with key-value pairs where key is the repo and value is the boolean value. jq removes the elements with false and creates an JSON array of the remaining keys. This is put into the outputs.repos variable for the next job.
name: repos
on:
workflow_dispatch:
inputs:
repo_1:
type: boolean
default: false
description: Use Repo 1?
repo_2:
type: boolean
default: false
description: Use Repo 2?
repo_3:
type: boolean
default: false
description: Use Repo 3?
jobs:
job1:
runs-on: ubuntu-latest
outputs:
repos: ${{ steps.step1.outputs.repos }}
steps:
- id: step1
run: >
echo '{
"repo_1": ${{ github.event.inputs.repo_1 }},
"repo_2": ${{ github.event.inputs.repo_2 }},
"repo_3": ${{ github.event.inputs.repo_3 }}
}'
| echo "repos=$( jq -c 'map_values(. // empty) | keys' )"
>> $GITHUB_OUTPUT
job2:
needs: job1
runs-on: ubuntu-latest
strategy:
matrix:
repo: ${{ fromJSON(needs.job1.outputs.repos) }}
steps:
- run: echo ${{ matrix.repo }}