如何访问GitHub操作中另一个工作流程检查的文件?
我可以访问由a caller/nater)的文件工作流?
我想拥有一个单独的 setup.yml 工作流,该工作流程检查存储库代码,然后在其他工作流中重复使用该工作流。
这是一个称为WorkFlow文件( setup.yml )的示例:
name: Set the project up
on: workflow_call
jobs:
setup:
name: Set the project up
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
这是呼叫者工作流文件( ci.yml ):
name: CI
on:
push:
branches:
- main
jobs:
setup:
uses: ./.github/workflows/setup.yml
test-the-project:
needs: setup
uses: ./.github/workflows/test.yml
Can I access the files that are checked out or generated by a caller/called workflow?
I want to have a separate setup.yml workflow that checks out the repository code and then reuse that workflow in other workflows.
Here is an example called workflow file (setup.yml):
name: Set the project up
on: workflow_call
jobs:
setup:
name: Set the project up
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '16'
Here is the caller workflow file (ci.yml):
name: CI
on:
push:
branches:
- main
jobs:
setup:
uses: ./.github/workflows/setup.yml
test-the-project:
needs: setup
uses: ./.github/workflows/test.yml
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果呼叫者工作流有要执行隐式的步骤,则可以执行此操作。
首先,安装节点时无需检查代码。然后将test.yl的工作内容放在ci.yml内部的不同工作中。
对于Exmaple:
You can do that if the caller workflow has the steps that you want to perform implicit.
First, you don't need to checkout the code when install node. Then put the content of the jobs of test.yml as differents jobs inside of ci.yml.
For exmaple: