GitHub 组合操作:找不到 'action.yml'

10
我正在尝试在我的仓库上创建一个复合动作,如下所示:
.github
├── actions
│   └── setup-composite.yml
└── workflows
    └── composite_test.yml

文件的内容是最基本的。
# setup-composite.yml

name: setup-env

runs:
  using: 'composite'
  steps:
    - uses: actions/setup-python@v4
      with:
        python-version: '3.9'

    - name: run dependencies
      shell: bash
      run: |
        pip install -r requirements.txt


然后我正在尝试使用引用复合工作流程。
# composite_test.yml

name: Composite Test
on:
  pull_request:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: composite
        uses: ./.github/actions/setup-composite

requirements.txt 文件的内容只是一些用于测试目的的软件包。

但是当这个工作流运行时,我会得到一个错误:Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/_actions/{profile}/{repo}/main/.github/actions/setup-composite'. Did you forget to run actions/checkout before running your local action?

据我所知,我按照 文档 中的所有步骤进行了操作。我还查看了多个其他答案,包括

以及GitHub讨论版块上的多个主题。

我的存储库是公开的。我尝试了几种uses: ./.github/actions/setup-composite语句的组合,包括通过分支引用,但我已经没有更多的尝试思路了。

1个回答

15

组合操作必须使用action.yml进行定义。

我做过类似的事情,尝试使用这种布局:

.github
├── actions
│   └── setup-composite
│      └── action.yml
└── workflows
    └── composite_test.yml

我的布局是一样的,但我还是得到了同样的错误。 - Alejandro Armas
2
没事了,我之前并没有检查与工作流相同的存储库,而是尝试使用我的 actions 目录路径。更多信息请参见此处:https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-an-action-in-the-same-repository-as-the-workflow - Alejandro Armas

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接