我想使用可重用工作流程并调用另外两个操作,下面是调用者和被调用工作流程的片段:
az-dev-img-ops-reusable.yml(称为工作流程1)
on:
workflow_call:
inputs:
cloudProvider:
required: true
type: string
imgAction:
required: true
type: string
envName:
required: true
type: string
productImage:
required: true
type: string
jobs:
image-actions:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/manage_images
with:
imgAction: ${{ inputs.imgAction }}
cloudProvider: ${{ inputs.cloudProvider }}
envName: ${{ inputs.envName }}
productImage: ${{ inputs.productImage }}
az-dev-tenant-ops-reusable.yml(称为工作流程2)
on:
workflow_call:
inputs:
cloudProvider:
required: true
type: string
envName:
required: true
type: string
action:
required: true
type: string
jobs:
tenant-actions:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- uses: ./.github/workflows/refresh_tenant
with:
cloudProvider: azure
envName: az-dev
action: pod_refresh
az-dev-cicd.yml(调用者工作流程)
on:
workflow_dispatch:
jobs:
init:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
image-operations:
uses: ./.github/workflows/az-dev-img-ops-reusable.yml
with:
imgAction: check
cloudProvider: azure
envName: az-dev
productImage: my-server
tenant-operations:
needs: image-operations
uses: ./.github/workflows/az-dev-tenant-ops-reusable.yml
with:
cloudProvider: azure
envName: az-dev
action: pod_refresh
但是在运行时,会抛出如下错误:
Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/opt/my-runner/_work/my-images/my-images/.github/workflows/manage_images'. Did you forget to run actions/checkout before running your local action?
通过网络检查解决方案并尝试所有即
- 进行操作/结账。
- 确保调用函数使用“uses”而不是步骤。
- 尝试了 repo/yaml 的绝对路径和相对路径。
但是一直没能解决。任何提示/帮助将不胜感激。
最佳答案
您的问题是您使用了以下语法:
uses: ./.github/workflows/manage_images
...引用目录。
以这种方式使用时,Github Action 解释器期望 local action (使用同一存储库中的操作)。
但是,要使用local actions
,您需要创建一个 action.yaml
文件放在目录中,但在您的情况下, the image您在评论中分享的内容表明您实际上有一个 manage_images.yaml
文件,引用工作流,而不是 manage_images
文件夹 action.yml
文件在其中。
要解决您的问题,如果出现此 manage_images.yaml
是 reusable workflow (在不同的工作流程中重复使用相同的工作流程),您需要添加 .yaml
在使用步骤结束时,如下所示:
uses: ./.github/workflows/manage_images.yaml
或者,如果您确实想使用本地操作,请转换此 manage_images.yaml
工作流到action.yaml文件,并将其放入 .github/workflows/manage_images
目录。
请注意这个 answer还可以为您提供有关本地操作和可重用工作流程的更多背景信息。
关于azure - 运行可重用工作流程时出错 - Github 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73401791/