Code of Conduct
What article on docs.github.com is affected? / What part(s) of the article would you like to see updated?
- workflow-syntax#onworkflow_dispatchinputsinput_idtype
- events-that-trigger-workflows#providing-inputs
- https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#providing-inputs
|
### Providing inputs |
|
|
|
You can configure custom-defined input properties, default input values, and required inputs for the event directly in your workflow. When you trigger the event, you can provide the `ref` and any `inputs`. When the workflow runs, you can access the input values in the `inputs` context. For more information, see [AUTOTITLE](/actions/learn-github-actions/contexts). |
|
|
|
{% data reusables.actions.inputs-vs-github-event-inputs %} |
|
|
|
This example defines inputs called `logLevel`, `tags`, and `environment`. You pass values for these inputs to the workflow when you run it. This workflow then prints the values to the log, using the `inputs.logLevel`, `inputs.tags`, and `inputs.environment` context properties. |
|
|
|
```yaml |
|
on: |
|
workflow_dispatch: |
|
inputs: |
|
logLevel: |
|
description: 'Log level' |
|
required: true |
|
default: 'warning' |
|
type: choice |
|
options: |
|
- info |
|
- warning |
|
- debug |
|
tags: |
|
description: 'Test scenario tags' |
|
required: false |
|
type: boolean |
|
environment: |
|
description: 'Environment to run tests against' |
|
type: environment |
|
required: true |
|
|
|
jobs: |
|
log-the-inputs: |
|
runs-on: ubuntu-latest |
|
steps: |
|
- run: | |
|
echo "Log level: $LEVEL" |
|
echo "Tags: $TAGS" |
|
echo "Environment: $ENVIRONMENT" |
|
env: |
|
LEVEL: {% raw %}${{ inputs.logLevel }}{% endraw %} |
|
TAGS: {% raw %}${{ inputs.tags }}{% endraw %} |
|
ENVIRONMENT: {% raw %}${{ inputs.environment }}{% endraw %} |
|
``` |
|
|
|
If you run this workflow from a browser you must enter values for the required inputs manually before the workflow will run. |
|
|
|
 |
|
|
|
You can also pass inputs when you run a workflow from a script, or by using {% data variables.product.prodname_cli %}. For example: |
|
|
|
```shell |
|
gh workflow run run-tests.yml -f logLevel=warning -f tags=false -f environment=staging |
|
``` |
|
|
|
For more information, see the {% data variables.product.prodname_cli %} information in [AUTOTITLE](/actions/managing-workflow-runs/manually-running-a-workflow). |
- contexts#inputs-context
Additional information
Input types are undocumented / contradicting
Particularly "environment", which, as per the documentation, seems to be a special sub-type of choice automatically populating the enum with the names of the repository's environment, but this is just a guess from the only screenshot available in the documentation
Given this, there might also even be other types
Code of Conduct
What article on docs.github.com is affected? / What part(s) of the article would you like to see updated?
docs/content/actions/reference/workflows-and-actions/workflow-syntax.md
Lines 264 to 266 in fa4d1bc
docs/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md
Lines 1076 to 1130 in fa4d1bc
docs/content/actions/reference/workflows-and-actions/workflow-syntax.md
Lines 162 to 164 in fa4d1bc
Additional information
Input types are undocumented / contradicting
Particularly "environment", which, as per the documentation, seems to be a special sub-type of choice automatically populating the enum with the names of the repository's environment, but this is just a guess from the only screenshot available in the documentation
Given this, there might also even be other types