有没有办法在单个runner中运行多个工作流程或在工作之间共享Github actions的工作空间?
在我的组织中,开发团队使用多个由多个团队创建和管理的可重用工作流程。Team build
创建和管理构建应用程序的build.yaml
。我的团队创建和管理执行应用程序构建数据分析并归档构建工件的analysis.yaml
。
开发团队计划在其应用程序工作流程中同时使用我们两个工作流程。为了使我的工作流程正常工作,我的工作流程需要访问所构建代码的目录(maven构建的target
目录,gradle构建的build
目录和npm构建的node_modules
目录)。
- 有没有办法在构建代码的runner上运行我的可重用工作流程?
- 我是否可以访问构建代码所在的工作空间(我搜索了其他答案并学习到可以使用上传动作
upload
和缓存动作cache
)?除此之外,还有其他方法可以实现这一点并在构建runner本身上运行我的可重用工作流程吗? - 使用组合动作而不是可重用工作流程是否更好实现此目的?
我有以下例子。
build.yaml
on:
workflow_call
inputs:
build:
description: Build type
required: true
jobs:
Build:
runs-on: self-hosted
steps:
- name: Building apps
- if: ${{inputs.build=='gradle'}}
run: |
gradle build
分析.yaml
on:
workflow_call
inputs:
analysis:
description: Build type
required: true
type: boolean
jobs:
Build:
runs-on: self-hosted
steps:
- name: Building apps
- if: ${{inputs.analysis}}
run: |
#Run ML build analysis
#Archive the build artifacts
工作流程.yaml
on:
push:
branches: [main]
jobs:
Build:
uses: buildteam/.github/workflows/build.yaml@main
with:
build: gradle
Analysis:
uses: analysis/.github/workflows/analysis.yaml@main
with:
analysis: true