如果变量环境是
dev
或qa
那么我希望有一个新的环境变量FINALENV
设置为nonprod
否则为prod
下面是我的工作流文件,来自
develop
[非主]分支
我的工作流程面临 2 个问题。
Run Workflow
按钮来手动触发工作流程。FINALENV
打印为non-prod
,因为满足if
条件但是它打印blank
.我是 github 工作流的新手。请建议。
---
name: CICD-RECYCLE
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:
inputs:
ENVIRONMENT:
type: choice
options:
- dev
- qa
- perf
- uat
- prod
jobs:
SETVARS:
runs-on: '1561'
steps:
- name: Print environment variable
run: |
echo "ENV is ${{ env.ENVIRONMENT }} only."
- name: Set environment variable for nonprod ENV
run: |
echo "FINALENV=nonprod" >> $GITHUB_ENV
if: ${{env.ENVIRONMENT == 'dev' || env.ENVIRONMENT == 'qa'}}
- name: Set environment variable for prod ENV
run: |
echo "FINALENV=prod" >> $GITHUB_ENV
if: ${{env.ENVIRONMENT != 'dev' || env.ENVIRONMENT != 'qa'}}
- name: Print environment variable for ENV
run: |
echo "FINALENV is ${{ env.FINALENV }} only."