GitHub操作错误:“需要“顶级'运行:'部分"" [英] GitHub Action error: "Top level 'runs:' section is required"

查看:80
本文介绍了GitHub操作错误:“需要“顶级'运行:'部分""的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行私有GitHub操作以在我的私有GitHub组织中工作.包含这些工作流模板"的私人存储库具有以下简单的文件结构,因为我只是想让最低限度发挥作用:

 .├──.git├──测试│├──action.yml 

action.yml 文件的内容为:

 名称:测试上:推职位:测试:名称:测试运行:ubuntu-latest脚步:-名称:Echo运行:回声Heyyyyy 

我正尝试在另一个私人仓库中使用具有以下内容的工作流文件来执行此操作:

 名称:测试上:推:分支机构:- 掌握职位:测试:名称:测试运行:ubuntu-latest脚步:-用途:actions/checkout @ v2和:信息库:< private-actions-repo>令牌:$ {{secrets.REPO_TOKEN}}路径:github-actions-名称:测试私人动作用途:./github-actions/test 

此操作运行时,出现以下错误: ## [错误]/home/runner/work/< private-repo>/../github-actions/test/action.yaml

尝试调试,我更新了使用模板的工作流程来 cat 此文件的文件内容:

 -名称:测试私人操作运行:猫./github-actions/test/action.yml 

..然后我得到了我期望的内容:

 >运行cat ./github-actions/test/action.yml名称:测试上:推职位:测试:名称:测试运行:ubuntu-latest脚步:-名称:Echo运行:回声Heyyyyy 

为什么从操作存储库中使用它时,它为什么不起作用,但是目标存储库中的内容完全相同?

解决方案

您必须区分工作流,操作和不同的操作类型.

工作流是顶级元素,不可组合.动作是可以在工作流中使用的构建块.您在 action.yml 中定义的动作实际上是一个工作流程,但应为复合运行步骤动作,即一种特定类型的动作,必须遵循:

I am trying to get a private GitHub action to work within my private GitHub org. The private repo that contains these workflow 'templates' has this simple file structure as I'm just trying to get the bare minimum to work:

.
├── .git
├── test
│   ├── action.yml

And the action.yml file contents are:

name: Test

on: push

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:

    - name: Echo
      run: |
        echo Heyyyyy

I am trying to use this action in another private repo with a workflow file with these contents:

name: Test

on:
  push:
    branches:
      - master

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repository: <private-actions-repo>
          token: ${{ secrets.REPO_TOKEN }}
          path: github-actions
      - name: Test private action
        uses: ./github-actions/test

When this action runs, I get the following error: ##[error]Top level 'runs:' section is required for /home/runner/work/<private-repo>/./github-actions/test/action.yaml

Trying to debug this, I updated the workflow that uses the template to cat the file contents of this file:

      - name: Test private action
        run: |
          cat ./github-actions/test/action.yml

..and I get the contents I would expect:

> Run cat ./github-actions/test/action.yml
name: Test

on: push

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:

    - name: Echo
      run: |
        echo Heyyyyy

Why would this not be working when using it from the action repo, but the exact same content works in the target repo?

解决方案

You have to differentiate between workflows, actions, and different action types.

Workflows are toplevel elements and not composable. Actions are building blocks that can be used in workflows. The action you defined in action.yml is actually a workflow but should be a composite run steps action, i.e. a specific type of action, that has to follow the rules given in: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions

You can find an example for a composite run steps action here: https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action#creating-an-action-metadata-file

If you use the following as action.yaml, it should work:

name: Test
description: 'composite run action'

runs:
  using: "composite"
  steps: 
    steps:
    - name: Echo
      shell: bash
      run: |
        echo Heyyyyy

这篇关于GitHub操作错误:“需要“顶级'运行:'部分""的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆