Complete reference for all inputs and outputs of the Ternary Operator Action.
Required: Yes
Type: String
Format: Comma-separated conditions
List of conditional expressions to evaluate. Each condition is evaluated independently and produces a corresponding output.
conditions: >-
SERVICE IN game,batch,api,
ENVIRONMENT == dev,
TEST == prod- Maximum 10 conditions
- Each condition must be a valid expression
- Conditions are separated by commas
- Whitespace is automatically trimmed
# Single line
conditions: 'SERVICE == game, ENVIRONMENT == prod'
# Multi-line with >-
conditions: >-
SERVICE IN game,batch,
ENVIRONMENT == dev
# Multi-line with |
conditions: |
SERVICE == game,
ENVIRONMENT == prodRequired: Yes
Type: String
Format: Comma-separated values
Values to return when corresponding conditions evaluate to TRUE.
true_values: 'service-true,environment-true,test-true'- Must have same number of values as conditions
- Each value corresponds to a condition by position
- Values can be any string
# Descriptive values
true_values: 'deploy-production,use-config-a,enable-feature'
# Boolean-like values
true_values: 'true,yes,1'
# Action identifiers
true_values: 'deploy,build,test'Required: Yes
Type: String
Format: Comma-separated values
Values to return when corresponding conditions evaluate to FALSE.
false_values: 'service-false,environment-false,test-false'- Must have same number of values as conditions
- Each value corresponds to a condition by position
- Values can be any string
# Descriptive values
false_values: 'skip-deploy,use-config-b,disable-feature'
# Boolean-like values
false_values: 'false,no,0'
# Action identifiers
false_values: 'skip,skip,skip'Required: No
Type: String
Default: '' (empty)
Format: Comma-separated values
Fallback values to use when a condition evaluation fails (e.g., due to an unexpected error). Must match the number of conditions if provided.
default_values: 'fallback1,fallback2,fallback3'- Graceful degradation when variables are missing
- Providing safe defaults for critical workflows
- Error-resilient condition evaluation
Required: No
Type: Boolean
Default: true
Controls whether string comparisons are case-sensitive. When set to false, all string comparisons (==, !=, IN, CONTAINS, STARTS_WITH, ENDS_WITH, MATCHES) become case-insensitive.
case_sensitive: falseSERVICE == Gamematchesgame,GAME,GameSERVICE IN Game,Batchmatchesgame,batch, etc.BRANCH CONTAINS Featurematchesfeature,FEATURE, etc.MATCHESpatterns usere.IGNORECASEflag
- Flexible environment variable matching
- User input normalization
- Cross-platform compatibility (case differences between OS)
Required: No
Type: Boolean
Default: false
Enable detailed debug logging for troubleshooting.
debug_mode: true- Shows variable substitution details
- Displays condition evaluation steps
- Reports warnings for undefined variables
- Shows intermediate processing results
• Debug: Starting validation
• Debug: Raw conditions string: 'SERVICE IN game,batch,api'
• Debug: Parsed 3 conditions:
1. SERVICE IN game,batch,api
• Debug: Variable SERVICE = game
• Debug: Checking if SERVICE='game' IN [game, batch, api]
• Debug: IN operator result: True
Success: Condition 1 is TRUE
- Development and testing
- Troubleshooting condition evaluation
- Verifying environment variable values
- Understanding processing flow
The action generates outputs named output_1 through output_10, corresponding to each evaluated condition. Additionally, a result output provides all results as a JSON object.
Type: JSON string
Format: {"output_1": "value1", "output_2": "value2", ...}
A combined JSON object containing all evaluated outputs, useful for passing results to downstream jobs or parsing multiple outputs at once.
- name: Evaluate
uses: somaz94/ternary-operator@v1
id: check
with:
conditions: 'SERVICE == game, ENV == prod'
true_values: 'yes,deploy'
false_values: 'no,skip'
- name: Use JSON Result
run: echo '${{ steps.check.outputs.result }}'
# Output: {"output_1": "yes", "output_2": "skip"}Name Pattern: output_N where N is 1-10
Type: String
Value: Either the corresponding true_value, false_value, or default_value
| Output | Corresponds To | Value Source |
|---|---|---|
output_1 |
1st condition | true_values[0] or false_values[0] |
output_2 |
2nd condition | true_values[1] or false_values[1] |
output_3 |
3rd condition | true_values[2] or false_values[2] |
output_4 |
4th condition | true_values[3] or false_values[3] |
output_5 |
5th condition | true_values[4] or false_values[4] |
output_6 |
6th condition | true_values[5] or false_values[5] |
output_7 |
7th condition | true_values[6] or false_values[6] |
output_8 |
8th condition | true_values[7] or false_values[7] |
output_9 |
9th condition | true_values[8] or false_values[8] |
output_10 |
10th condition | true_values[9] or false_values[9] |
- name: Evaluate
uses: somaz94/ternary-operator@v1
id: check
with:
conditions: 'SERVICE == game'
true_values: 'deploy'
false_values: 'skip'
- name: Use Output
run: echo "Result: ${{ steps.check.outputs.output_1 }}"
- name: Conditional Step
if: steps.check.outputs.output_1 == 'deploy'
run: ./deploy.shjobs:
evaluate:
runs-on: ubuntu-latest
outputs:
deploy_action: ${{ steps.check.outputs.output_1 }}
config_type: ${{ steps.check.outputs.output_2 }}
steps:
- name: Check
id: check
uses: somaz94/ternary-operator@v1
with:
conditions: 'SERVICE == game, ENVIRONMENT == prod'
true_values: 'deploy,prod-config'
false_values: 'skip,dev-config'
deploy:
needs: evaluate
if: needs.evaluate.outputs.deploy_action == 'deploy'
runs-on: ubuntu-latest
steps:
- run: echo "Deploying..."Limit: 10 conditions per action call
Rationale: Keeps outputs manageable and promotes clarity
[X] Error: Maximum number of conditions (10) exceeded. Found 11 conditions
If you need more than 10 conditions, split them into multiple action calls:
- name: First Batch
uses: somaz94/ternary-operator@v1
id: batch1
with:
conditions: # conditions 1-10
- name: Second Batch
uses: somaz94/ternary-operator@v1
id: batch2
with:
conditions: # conditions 11-20All arrays must have the same length:
conditionscounttrue_valuescountfalse_valuescountdefault_valuescount (if provided)
# [X] This will fail
conditions: 'A == 1, B == 2' # 2 conditions
true_values: 'yes' # 1 value
false_values: 'no,never' # 2 values
# Error: Number of conditions (2), true values (1), and false values (2) must match# [O] This works
conditions: 'A == 1, B == 2' # 2 conditions
true_values: 'yes,ok' # 2 values
false_values: 'no,fail' # 2 valuesEnvironment variables used in conditions must:
- Start with an uppercase letter
- Contain only uppercase letters, numbers, and underscores
- Be set before the action runs
SERVICE # [O]
ENVIRONMENT # [O]
MY_VAR # [O]
API_V2 # [O]
COUNT # [O]service # [X] lowercase
my-var # [X] contains hyphen
2ND_VAR # [X] starts with numberThe action reads environment variables set in the workflow.
env:
SERVICE: game
ENVIRONMENT: prod
jobs:
test:
steps:
- uses: somaz94/ternary-operator@v1
with:
conditions: 'SERVICE == game'jobs:
test:
env:
SERVICE: game
ENVIRONMENT: prod
steps:
- uses: somaz94/ternary-operator@v1steps:
- name: Set Variable
run: echo "SERVICE=game" >> $GITHUB_ENV
- uses: somaz94/ternary-operator@v1
env:
ENVIRONMENT: prod
with:
conditions: 'SERVICE == game && ENVIRONMENT == prod'- name: Set Variables
uses: somaz94/env-output-setter@v1
with:
env_key: 'SERVICE,ENVIRONMENT'
env_value: 'game,prod'
- uses: somaz94/ternary-operator@v1
with:
conditions: 'SERVICE == game'The action automatically substitutes environment variables in conditions:
# Before substitution
conditions: 'SERVICE == game && ENVIRONMENT == prod'
# After substitution (if SERVICE=game, ENVIRONMENT=qa)
conditions: '"game" == "game" && "qa" == "prod"'If a variable is not set:
- The condition evaluates to FALSE
- A warning is shown in debug mode
# SERVICE is not set
conditions: 'SERVICE == game'
# Debug output:
• Debug: Warning: Variable SERVICE is not set or empty
• Debug: Condition 1 is FALSEname: Complete API Demo
on: [workflow_dispatch]
jobs:
demo:
runs-on: ubuntu-latest
outputs:
result1: ${{ steps.evaluate.outputs.output_1 }}
result2: ${{ steps.evaluate.outputs.output_2 }}
result3: ${{ steps.evaluate.outputs.output_3 }}
steps:
- uses: actions/checkout@v6
- name: Set Environment Variables
uses: somaz94/env-output-setter@v1
with:
env_key: 'SERVICE,ENVIRONMENT,VERSION'
env_value: 'game,prod,1.5.0'
output_key: 'SERVICE,ENVIRONMENT,VERSION'
output_value: 'game,prod,1.5.0'
- name: Evaluate Conditions
id: evaluate
uses: somaz94/ternary-operator@v1
with:
# Input 1: conditions (required)
conditions: >-
SERVICE IN game,batch,api,
ENVIRONMENT == prod,
VERSION >= 1.5
# Input 2: true_values (required)
true_values: >-
valid-service,
production-deploy,
new-version
# Input 3: false_values (required)
false_values: >-
invalid-service,
non-prod-deploy,
old-version
# Input 4: debug_mode (optional)
debug_mode: true
# Output 1: output_1
- name: Check Service
run: echo "Service validation: ${{ steps.evaluate.outputs.output_1 }}"
# Output 2: output_2
- name: Check Environment
run: echo "Environment check: ${{ steps.evaluate.outputs.output_2 }}"
# Output 3: output_3
- name: Check Version
run: echo "Version check: ${{ steps.evaluate.outputs.output_3 }}"
# Using outputs in conditionals
- name: Deploy
if: |
steps.evaluate.outputs.output_1 == 'valid-service' &&
steps.evaluate.outputs.output_2 == 'production-deploy' &&
steps.evaluate.outputs.output_3 == 'new-version'
run: echo "All checks passed, deploying..."- Operators Reference - Detailed operator documentation
- Usage Examples - Practical usage patterns
- Troubleshooting - Common issues and solutions