cod*_*lot 11 github github-actions
我在 GitHub Action 中遇到了奇怪的行为workflow_call。
基本上,初始设置后一切正常,但是当我编辑工作流程文件的输入参数时,它不使用更新的值。很难用语言来解释,所以让我给你举个例子。
考虑这个基本设置:
文件:start-pipeline.yml
name: Start Pipeline
on:
workflow_dispatch:
inputs:
release_type:
required: true
type: choice
options:
- patch
- minor
- major
jobs:
call-sub-workflow:
uses: codezalot/workflow-call-issue/.github/workflows/sub-workflow.yml@main
with:
release_type: ${{ github.event.inputs.release_type }}
Run Code Online (Sandbox Code Playgroud)
文件:子工作流程.yml
name: Sub Workflow
on:
workflow_call:
inputs:
release_type:
type: string
required: true
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Print Inputs
run: |
echo "Release Type: ${{ github.event.inputs.release_type }}"
Run Code Online (Sandbox Code Playgroud)
然后,我使用值补丁启动管道,子工作流程会很好地打印输入:

然后,我更新工作流程文件并添加额外的输入值,如下所示:
文件:start-pipeline.yml
...
jobs:
call-sub-workflow:
uses: codezalot/workflow-call-issue/.github/workflows/sub-workflow.yml@main
with:
release_type: ${{ github.event.inputs.release_type }}
some_other_value: ${{ github.event.inputs.release_type }}
Run Code Online (Sandbox Code Playgroud)
文件:子工作流程.yml
...
inputs:
...
some_other_value:
type: string
required: true
jobs:
...
run: |
echo "Release Type: ${{ github.event.inputs.release_type }}"
echo "Release Type: ${{ github.event.inputs.some_other_value }}"
Run Code Online (Sandbox Code Playgroud)
然后,我再次运行管道,一次使用release_type patch,一次使用minor。但是,缺少some_other_value值,请参阅:

。
我已经研究这个问题几个小时了,但我不明白出了什么问题。因为它似乎确实使用了最新的 SHA 版本的文件,只是输入参数导致了问题。
有谁知道这是怎么回事?
Mat*_*att 16
根据文档:“当工作流被workflow_call事件触发时,被调用工作流中的事件负载与调用工作流中的事件负载相同。” 换句话说,上下文event中的参数github与原始工作流的参数相同。
github.event.input.some_other_value因此,由于原始工作流程没有此输入,因此没有参数。对于可重用工作流程中定义的输入,您可以使用包含传递到可重用工作流程的输入属性的inputs上下文。
总而言之,这是一个工作的sub-workflow.yml文件:
name: Sub Workflow
on:
workflow_call:
inputs:
release_type:
type: string
required: true
some_other_value:
type: string
required: true
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Print Inputs
run: |
echo "Release Type: ${{ inputs.release_type }}"
echo "Release Type: ${{ inputs.some_other_value }}"
Run Code Online (Sandbox Code Playgroud)
结果:
| 归档时间: |
|
| 查看次数: |
7687 次 |
| 最近记录: |