Github 操作上的工作流之间的依赖关系 [英] Dependencies Between Workflows on Github Actions
本文介绍了Github 操作上的工作流之间的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有两个工作流程的 monorepo:
I have a monorepo with two workflows:
.github/workflows/test.yml
name: test
on: [push, pull_request]
jobs:
test-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: test packages
run: |
yarn install
yarn test
...
.github/workflows/deploy.yml
name: deploy
on:
push:
tags:
- "*"
jobs:
deploy-packages:
runs-on: ubuntu-latest
needs: test-packages
steps:
- uses: actions/checkout@v1
- name: deploy packages
run: |
yarn deploy
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
...
这不起作用,我无法在另一个工作流中引用作业:
This doesn't work, I can't reference a job in another workflow:
### ERRORED 19:13:07Z
- Your workflow file was invalid: The pipeline is not valid. The pipeline must contain at least one job with no dependencies.
有没有办法在工作流之间创建依赖关系?
我想要的是在标签上运行 test.yml
然后 deploy.yml
和仅在推送和拉取请求上运行 test.yml
.我不想在工作流之间重复作业.
What I want is to run test.yml
then deploy.yml
on tags, and test.yml
only on push and pull requests. I don't want to duplicate jobs between workflows.
推荐答案
现在可以使用 workflow_run.
使用此配置,Release
工作流程将在 Run Tests
工作流程完成后工作.
Using this config, the Release
workflow will work when the Run Tests
workflow is completed.
name: Release
on:
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed
这篇关于Github 操作上的工作流之间的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文