如何仅在发布后另一个工作流程运行工作流?
我有这样的github工作流程:
name: publish
on:
release:
types: [published]
workflow_run:
workflows: [test]
types: [completed]
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo 'The test workflow passed'
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The test workflow failed'
我想在发行版上运行发布
工作流程,然后传递 test
之后。但是,在每个 test
完成后,它都会在每个推动下运行到 main
。
如何使发布
仅在版本时运行?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案的问题是,使用使用多个事件导致每个事件触发自己的工作流程。因此,工作流程无法分别引用“测试完成”和“发行”条件。当前在GitHub动作中无法做到这一点。
最简单的选择是使您的测试工作流程在每个推送到MAIN和发行时运行,并添加最终作业,如果版本触发工作流程,该作业将运行。因此,您将其附加到您的测试工作流程中:
每当创建发布时,这将具有重复测试作业的缺点,但是只要您的发行版不太频繁,这将可以忽略不计。
The issue with your solution is that using multiple events causes each event to trigger its own workflow. So the workflow run has no way of referencing both the "test complete" and the "on release" conditions separately. Currently there is no way of doing this in GitHub Actions.
The easiest option would be to make your testing workflow run on every push to main and on release, and add a final job that will run if a release triggered the workflow. So you would append this to your test workflow:
This will have the downside of the testing job being repeated whenever a release is created, but this is negligible as long as your releases are not too frequent.