我该如何将参数inputs.custom
传递给这个操作代码:
jobs:
test-custom:
name: Test Custom
uses: ./.github/workflows/work4-${{ inputs.custom }}.yml
完整的工作示例:
第一个工作流程 work1-build.yml
:
name: Start workflow fail
on: [push]
jobs:
build-fail:
name: Build with other workflow
uses: ./.github/workflows/work3-build-fail.yml
with:
custom: custom-name1
第二个工作流程 work3-build-fail.yml
:
name: Build fail with input test
on:
workflow_call:
inputs:
custom:
description: Some custom string
required: true
type: string
jobs:
test-custom:
name: Test Custom
uses: ./.github/workflows/work4-${{ inputs.custom }}.yml
第三个工作流程 work4-custom-name1.yml
name: Custom 1
on:
workflow_call
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "IN CUSTOM 1"
上面的示例会使GitHub返回一个错误:
Invalid workflow file
error parsing called workflow
".github/workflows/work1-build.yml"
-> "./.github/workflows/work3-build-fail.yml" (source branch with sha:720087c8794e76f52277f9b1229b44ea65ab89d5)
--> "./.github/workflows/work4-${{ inputs.custom }}.yml"
: failed to fetch workflow: workflow was not found.
我可以成功地将${{ inputs.custom }}
添加到:
test-print:
runs-on: ubuntu-latest
name: Print input
steps:
- name: Step print input
run: echo ${{ inputs.custom }}
文档中没有包含任何使用uses
参数的示例:
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses
uses: ./.github/actions/run-${{ inputs.custom }}
看起来,您正在重用同一存储库中的工作流程。根据调用可重用工作流程,“您可以使用uses
关键字调用可重用工作流程。与在工作流程中使用操作时不同,您直接在作业中调用可重用工作流程,而不是在作业步骤中调用。”。因此,您需要修复调用该可重用工作流程的语法。 - Azeemuses:
上不能使用inputs,如果你查看你的作业,所有可重复使用的操作/工作流在运行任何内容之前都是源。如果你现在引用操作而不是工作流,那么你的错误是否不同了? - aknosis