我想通过两种方式运行我的 Github 工作流程:
现在,一切都运行良好,直到我添加输入参数。之后,cron 作业正在运行,但不选择默认值。
这是我的 yaml:
name: WebDriverIO Automation
on:
workflow_dispatch:
inputs:
typeOfTesting:
type: choice
description: Select Type of Test
default: 'stage-test-local-All'
required: true
options:
- stage-test-local-All
- stage-test
- stage-test-local-Sanity
- prod-test
branches:
- workingBranch
- JSNew
schedule:
- cron: "*/5 * * * *"
Run Code Online (Sandbox Code Playgroud)
Jom*_*n68 20
inputs仅可用于由workflow_dispatch 事件触发的工作流(以及由已分派工作流调用的任何工作流)。
您可以使用||表达式运算符设置输入参数的默认值。例如:
on:
schedule:
- cron: '15 0,18 * * 0-5'
workflow_dispatch:
inputs:
logLevel:
required: true
type: string
jobs:
test:
uses: ./.github/workflows/run-job-with-params.yml
secrets: inherit
with:
springProfile: 'production'
logLevel: ${{ inputs.logLevel || 'DEBUG' }}
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,logLevel参数设置DEBUG为 cron 触发工作流时。当作业被调度事件触发时,它会被设置为输入值。
下面的代码有效
name: WebDriverIO Automation
on:
workflow_dispatch:
inputs:
typeOfTesting:
type: choice
description: Select Type of Test
default: 'stage-test-local-All'
required: true
options:
- stage-test-local-All
- stage-test
- stage-test-local-Sanity
- prod-test
branches:
- workingBranch
schedule:
- cron: "*/5 * * * *"
...
..
..
- name: Test
run: |
if [ ${{ github.event.inputs.typeOfTesting }} != "" ]; then
npm run ${{ github.event.inputs.typeOfTesting }}
else
npm run stage-test-local-All
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12247 次 |
| 最近记录: |