我正在尝试让一个私有GitHub操作在我的私有GitHub组织中工作。包含这些工作流“模板”的私有回购具有以下简单的文件结构,因为我只是试图获得最低限度的工作:
.
├── .git
├── test
│ ├── action.ymlaction.yml文件的内容是:
name: Test
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Echo
run: |
echo Heyyyyy我试图在另一个具有以下内容的工作流文件的私有回购中使用此操作:
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当此操作运行时,我得到以下错误:##[error]Top level 'runs:' section is required for /home/runner/work/<private-repo>/./github-actions/test/action.yaml
为了调试这一点,我更新了使用模板的工作流以cat该文件的文件内容:
- name: Test private action
run: |
cat ./github-actions/test/action.yml..and我得到了我期望的内容:
> 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为什么当从动作回购中使用它时,这个方法不能工作,但是在目标回购中完全相同的内容工作呢?
发布于 2020-09-02 16:54:53
您必须区分工作流、操作和不同的操作类型。
工作流是分层元素,不能组合。操作是可以在工作流中使用的构建块。您在action.yml中定义的操作实际上是一个工作流,但应该是一个composite run steps action,即特定类型的操作,必须遵循:https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions中给出的规则。
您可以在这里找到composite run steps action的一个示例:https://docs.github.com/en/actions/creating-actions/creating-a-composite-run-steps-action#creating-an-action-metadata-file
如果您将以下内容用作action.yaml,则它应该可以工作:
name: Test
description: 'composite run action'
runs:
using: "composite"
steps:
steps:
- name: Echo
shell: bash
run: |
echo Heyyyyyhttps://stackoverflow.com/questions/63710029
复制相似问题