我要加入的GitHub工作流程中有两个步骤:
- name: my action on environment a
uses: myAction@v1
if: github.ref != 'refs/heads/master'
with:
config 1: some config identical to other step
config 2: some other config identical to other step
environment: a
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: my action on environment b
uses: myAction@v1
if: github.ref == 'refs/heads/master'
with:
config 1: some config identical to other step
config 2: some other config identical to other step
environment: b
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
唯一的区别是环境输入。如果是master(使用b环境),如果不使用a ...
是否可以在某种if语句中组合此值以避免重复步骤?
答案 0 :(得分:0)
是的。一种方法是将输入手动放在顶部的环境中。 with
中的键为大写字母,并以INPUT_
为前缀,然后在env中进行设置。 core.getInput()
就是这样捡起来的。
您可以将它们作为顶部的配置添加到.yml
中-请参见here。