on:
push
concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers.
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
...
Run Code Online (Sandbox Code Playgroud)
这会为每个分支创建一个单独的组,并在稍后推送/强制推送到分支时取消构建。可悲的是,这也取消了master构建,这是我不想要的。所有提交都master应该完成运行,因此很容易看到何时出现问题。
我本质上是在寻找一种方式来表达:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
if: github.ref != 'refs/heads/master'
Run Code Online (Sandbox Code Playgroud)
thi*_*ign 19
您可以cancel-in-progress根据默认分支指定:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
Run Code Online (Sandbox Code Playgroud)
TWi*_*Rob 11
GitHub Actions 表达式语法中没有三元运算符,但我找到了一些解决方法:http://rickluna.com/wp/tag/fake-ternary/是一篇关于此的很棒的文章。
github头分支的提交哈希在上下文对象中可用,形式为github.sha。
就我而言,假三元的真实性不是问题,它实际上总是必须有一个值,所以我可以这样做:
concurrency:
# Documentation suggests ${{ github.head_ref }}, but that's only available on pull_request/pull_request_target triggers, so using ${{ github.ref }}.
# On master, we want all builds to complete even if merging happens faster to make it easier to discover at which point something broke.
group: ${{ github.ref == 'refs/heads/master' && format('ci-master-{0}', github.sha) || format('ci-{0}', github.ref) }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4677 次 |
| 最近记录: |