我希望为我的GitHub Action输入参数创建一个下拉列表。这应该有助于从下拉列表中选择一个值,就像选择分支的选项一样。
workflow_dispatch
时,现在可以使用choice
、boolean
和environment
输入,而不仅仅是字符串。 choice
是下拉菜单,boolean
是复选框,environment
类似于choice
,但会自动填充为在仓库设置中配置的所有环境。
这里是一个使用新类型的示例工作流程:
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 }}
inputs
上下文访问输入内容, 而不需要使用github.event.inputs
。
inputs.inputname
和github.event.inputs.inputname
并不总是相同的。例如,假设一个调度的工作流程调用一个操作。工作流程和操作具有不同的输入。当你在操作内部引用inputs.inputname
和github.event.inputs.inputname
时,inputs.inputname
将是操作的输入,而github.event.inputs.inputname
将是工作流程的输入。 - undefined