在可重用工作流程中“找不到‘action.yml’”

cha*_*198 3 github github-actions

我有以下结构:

\n
.github\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 send_alerts.yml\n
Run Code Online (Sandbox Code Playgroud)\n

现在主要是,我正在使用

\n
jobs:\n  main:\n    steps:\n      - name: Git Checkout\n        uses: actions/checkout@v3\n      - name: some job\n        run: |\n          ......\n  send_alerts:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - uses: ./.github/workflows/send_alerts.yml@feature/workflow1\n        with:\n          provision_status: "Success"\n  \n
Run Code Online (Sandbox Code Playgroud)\n

在我的send_alerts.yml

\n
name: Creating and Sending Alerts/Status\non:\n  workflow_call:\n  \n    provision_status:\n      required: true\n      type: string\n\njobs:\n  create_send_alerts:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Git Checkout\n        uses: actions/checkout@v3\n      - name: Some other jobs\n        run: |\n        .....\n
Run Code Online (Sandbox Code Playgroud)\n

所以这让我犯了错误:

\n
Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/git-repo/.github/workflows/send_alerts.yml@feature/workflow1'. Did you forget to run actions/checkout before running your local action?\n
Run Code Online (Sandbox Code Playgroud)\n

所以我的问题是为什么它抱怨send_alertsmain 中的操作?而在 main.yml 中相同actions/checkout@v3可以正常工作吗?

\n

我尝试了 actions/checkout@v2 和 v3 在所有情况下都有相同的错误

\n

Ben*_* W. 5

至少有以下三点是错误的:

  1. 您正在像操作一样调用可重用的工作流程。对可重用工作流程的调用取代了整个作业,而不仅仅是一个步骤。

  2. 当您使用相对路径引用同一存储库中的工作流(或操作)时,不得添加后缀@version。如果您查看错误消息,运行程序会将其解释为目录名称。

两者结合起来会产生这样的结果:

  send_alerts:
    uses: ./.github/workflows/send_alerts.yml
    with:
      provision_status: "Success"
Run Code Online (Sandbox Code Playgroud)
  1. 您必须inputs在可重用工作流程中的对象中声明参数:

    on:
      workflow_call:
        inputs:
          provision_status:
            required: true
            type: string
    
    Run Code Online (Sandbox Code Playgroud)