第一次處理 Github 操作。在我的 .yml 檔案中,我有以下內容
on:
workflow_dispatch:
branches:
- main
inputs:
environment:
type: choice
description: 'Select environment to deploy in'
required: true
options:
- dev
- non-prod
- prod
- staging
根據選項我需要做以下事情
用于舞臺
- name: build
run: CI=false yarn build-staging
對于非產品
- name: build
run: CI=false yarn build
您能否就如何實作這一目標向我提供一些建議?
uj5u.com熱心網友回復:
最簡單的方法是對作業流中的作業使用 if 條件,例如:
on:
workflow_dispatch:
branches:
- main
inputs:
environment:
type: choice
description: 'Select environment to deploy in'
required: true
options:
- dev
- non-prod
- prod
- staging
jobs:
staging:
runs-on: ubuntu-latest
if: inputs.environment == 'staging'
steps:
- name: build
run: CI=false yarn build-staging
prod:
runs-on: ubuntu-latest
if: inputs.environment == 'prod'
steps:
- name: build
run: CI=false yarn build
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/534452.html
標籤:知乎github-动作
