如何访问GitHub Actions中另一个工作流检查出的文件?



我可以访问由调用者/被调用者工作流签出或生成的文件吗?

我想有一个单独的设置。Yml工作流,检出存储库代码,然后在其他工作流中重用该工作流。

下面是一个叫做工作流文件(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

如果调用者工作流具有您想要隐式执行的步骤,则可以这样做。

首先,在安装节点时不需要签出代码。然后把作业的内容进行测试。在ci.yml中作为不同的作业。

例子:

name: CI
on:
push:
branches:
- main
jobs:
setup:
uses: ./.github/workflows/setup.yml
test-the-project:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check Node version and install
run: node -v && npm i

最新更新