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

发布于 2025-02-07 05:44:07 字数 940 浏览 1 评论 0原文

我可以访问由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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迎风吟唱 2025-02-14 05:44:07

如果呼叫者工作流有要执行隐式的步骤,则可以执行此操作。

首先,安装节点时无需检查代码。然后将test.yl的工作内容放在ci.yml内部的不同工作中。

对于Exmaple:

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

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:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文