我正在定义一个引用另一个 yaml 文件的 github 操作脚本,希望能够以更有条理的方式进行配置。
这是我的工作文件,名为deploy.yml
在路径中./.github/workflows/
,其中第一个.
是我的项目的根文件夹。
....
jobs:
UnitTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/unittest.yml
在相同的./.github/workflows/
文件夹中,我创建了另一个文件,名为unittest.yml
如下:
name: "UnitTest"
description: "Perform Unit Test"
runs:
# using: "composite"
- name: Dependency
run: |
echo "Dependency setup commands go here"
- name: UnitTest
run: make test.unit
但是,当我尝试使用本地测试脚本时act https://github.com/nektos/act用命令act --secret-file .secrets --container-architecture linux/amd64
,我收到以下错误:
[Deploy/UnitTest] ✅ Success - Main actions/checkout@v3
[Deploy/UnitTest] ⭐ Run Main ./.github/workflows/unittest.yml
[Deploy/UnitTest] ❌ Failure - Main ./.github/workflows/unittest.yml
[Deploy/UnitTest] file does not exist
[Deploy/UnitTest] ???? Job failed
我尝试只输入文件名unittest.yml
or ./unittest.yml
or myrepo_name/.github/workflows/unittest.yml
或将文件放入子文件夹中,例如本文档的步骤 2 https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-inputs-and-secrets-in-a-reusable-workflow如图所示,但一切都没有运气。
基于以下示例运行组合动作 https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsuses,我想这应该可行。
有人请建议吗?
附:您可能已经注意到注释行using: "composite"
in the unittest.yml
。如果我取消注释该行,我将收到错误:
Error: yaml: line 3: did not find expected key