azure - 运行可重用工作流程时出错 - Github 操作

标签 azure github github-actions

我想使用可重用工作流程并调用另外两个操作,下面是调用者和被调用工作流程的片段:

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?

通过网络检查解决方案并尝试所有即

  1. 进行操作/结账。
  2. 确保调用函数使用“uses”而不是步骤。
  3. 尝试了 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.yamlreusable 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/

相关文章:

azure - 使用 ACR 和托管标识配置 Azure WebApp

github - 从 Github API 查找用户的总贡献

git push 删除服务器上不在本地的文件

yaml - GitHub 不允许将 secret 传递给可重用的工作流程

firebase - 在 flutter 项目中替换 firebase json 的 Github Action

azure - Azure 中允许使用哪些 IP 进行 Github 操作?

azure - azure 中消耗的资源

ios - ADAL 身份验证需要设备管理

azure - 使用 Google 服务帐户登录 Azure B2C

java - 如何为 Github API 验证基本 Java 程序