[英]Conditionally append a string in a GitHub actions workflow
Is it possible to use GitHub Actions expressions to concatenate a string conditionally?是否可以使用 GitHub Actions 表达式有条件地连接字符串?
Eg like I'm trying to do in below example.例如,就像我在下面的示例中尝试做的那样。
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist ${{ if (startsWith(github.ref, 'refs/tags/')) { '--snapshot' }}
You could use the following which would return -additional-arg
if the condition is satisfied and empty string otherwise:您可以使用以下内容,如果条件满足则返回
-additional-arg
否则为空字符串:
${{ (startsWith(github.ref, 'refs/tags/') && '-additional-arg') || '' }}
Example:例子:
name: Test arguments
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist ${{ (startsWith(github.ref, 'refs/tags/') && '--snapshot') || '' }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.