{"id":25841621,"url":"https://github.com/somaz94/ternary-operator","last_synced_at":"2026-06-12T05:32:13.092Z","repository":{"id":245373485,"uuid":"817674081","full_name":"somaz94/ternary-operator","owner":"somaz94","description":"ternary-operator","archived":false,"fork":false,"pushed_at":"2026-03-26T07:23:46.000Z","size":218,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-27T02:12:59.728Z","etag":null,"topics":["automation","ci-cd","conditional","devops","expressions","github-action","github-actions","python","string-processing","ternary-operator","workflow"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/ternary-operator-action","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/somaz94.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-20T07:58:06.000Z","updated_at":"2026-03-26T07:23:50.000Z","dependencies_parsed_at":"2024-10-31T09:27:09.943Z","dependency_job_id":"3eecd89b-bbc2-49be-a4ac-0fbe4735ffe0","html_url":"https://github.com/somaz94/ternary-operator","commit_stats":null,"previous_names":["somaz94/ternary-operator"],"tags_count":14,"template":false,"template_full_name":"actions/container-action","purl":"pkg:github/somaz94/ternary-operator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somaz94%2Fternary-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somaz94%2Fternary-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somaz94%2Fternary-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somaz94%2Fternary-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/somaz94","download_url":"https://codeload.github.com/somaz94/ternary-operator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/somaz94%2Fternary-operator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34231214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","ci-cd","conditional","devops","expressions","github-action","github-actions","python","string-processing","ternary-operator","workflow"],"created_at":"2025-03-01T05:29:51.742Z","updated_at":"2026-06-12T05:32:13.086Z","avatar_url":"https://github.com/somaz94.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ternary Operator Action\n\n![CI](https://github.com/somaz94/ternary-operator/actions/workflows/ci.yml/badge.svg)\n[![License](https://img.shields.io/github/license/somaz94/ternary-operator)](LICENSE)\n![Latest Tag](https://img.shields.io/github/v/tag/somaz94/ternary-operator)\n[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Ternary%20Operator-blue?logo=github)](https://github.com/marketplace/actions/ternary-operator-action)\n\nA GitHub Action for evaluating conditional expressions and setting dynamic outputs based on the results. Perfect for creating flexible, condition-driven workflows.\n\n\u003cbr/\u003e\n\n## Features\n\n- **Multiple Conditions**: Evaluate up to 10 conditions in a single step\n- **Rich Operators**: Support for comparison (`==`, `!=`, `\u003c`, `\u003e`, `\u003c=`, `\u003e=`), logical (`\u0026\u0026`, `||`, `NOT`), special (`IN`), string (`CONTAINS`, `STARTS_WITH`, `ENDS_WITH`), regex (`MATCHES`), and validation (`EMPTY`, `NOT_EMPTY`) operators\n- **Case Sensitivity Control**: Optional case-insensitive comparison mode\n- **Default Values**: Fallback values when condition evaluation fails\n- **JSON Result Output**: Combined JSON output for easy multi-condition access\n- **Simple Syntax**: Clean, readable condition expressions\n- **Debug Mode**: Detailed logging for troubleshooting\n- **Zero Dependencies**: Lightweight Docker-based action\n- **Fast Execution**: Efficient condition evaluation\n\n\u003cbr/\u003e\n\n## Quick Start\n\n```yaml\nname: Conditional Deploy\non: [push]\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v6\n      \n      # Set environment variables\n      - name: Set Variables\n        run: |\n          echo \"SERVICE=game\" \u003e\u003e $GITHUB_ENV\n          echo \"ENVIRONMENT=prod\" \u003e\u003e $GITHUB_ENV\n      \n      # Evaluate conditions\n      - name: Check Deployment Rules\n        id: check\n        uses: somaz94/ternary-operator@v1\n        with:\n          conditions: 'SERVICE IN game,batch \u0026\u0026 ENVIRONMENT == prod'\n          true_values: 'deploy-allowed'\n          false_values: 'deploy-blocked'\n      \n      # Use the result\n      - name: Deploy\n        if: steps.check.outputs.output_1 == 'deploy-allowed'\n        run: ./deploy.sh\n```\n\n\u003cbr/\u003e\n\n## Use Cases\n\n- **Conditional Deployments**: Deploy based on service, environment, or branch\n- **Dynamic Configuration**: Select configs based on multiple conditions\n- **Feature Flags**: Enable/disable features conditionally\n- **Multi-Environment CI/CD**: Different strategies per environment\n- **Resource Scaling**: Adjust resources based on conditions\n\n\u003cbr/\u003e\n\n## Documentation\n\n\u003cbr/\u003e\n\n### Core Documentation\n- **[API Reference](docs/api.md)** - Complete input/output specification\n- **[Operators Guide](docs/operators.md)** - All supported operators with examples\n- **[Usage Examples](docs/usage.md)** - Real-world patterns and scenarios\n- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions\n- **[Development Guide](docs/development.md)** - Contributing and local testing\n\n\u003cbr/\u003e\n\n### Operators at a Glance\n\n| Category | Operators | Example |\n|----------|-----------|---------|\n| **Comparison** | `==` `!=` `\u003c` `\u003e` `\u003c=` `\u003e=` | `VERSION \u003e= 1.5` |\n| **Logical** | `\u0026\u0026` `\\|\\|` `NOT` | `SERVICE == game \u0026\u0026 ENV == prod` |\n| **Special** | `IN` | `SERVICE IN game,batch,api` |\n| **String** | `CONTAINS` `STARTS_WITH` `ENDS_WITH` | `BRANCH STARTS_WITH feature/` |\n| **Regex** | `MATCHES` | `TAG MATCHES ^v[0-9]+\\.[0-9]+$` |\n| **Validation** | `EMPTY` `NOT_EMPTY` | `API_KEY NOT_EMPTY` |\n\n[→ See detailed operator documentation](docs/operators.md)\n\n\u003cbr/\u003e\n\n## Common Examples\n\n\u003cbr/\u003e\n\n### Example 1: Simple Condition\n\n```yaml\n- uses: somaz94/ternary-operator@v1\n  id: check\n  with:\n    conditions: 'ENVIRONMENT == prod'\n    true_values: 'production-config'\n    false_values: 'development-config'\n```\n\n\u003cbr/\u003e\n\n### Example 2: IN Operator (Simplified OR)\n\n```yaml\n- uses: somaz94/ternary-operator@v1\n  id: check\n  with:\n    # Instead of: SERVICE == game || SERVICE == batch || SERVICE == api\n    conditions: 'SERVICE IN game,batch,api'\n    true_values: 'valid-service'\n    false_values: 'invalid-service'\n```\n\n\u003cbr/\u003e\n\n### Example 3: Multiple Conditions\n\n```yaml\n- uses: somaz94/ternary-operator@v1\n  id: checks\n  with:\n    conditions: \u003e-\n      SERVICE IN game,batch,api,\n      ENVIRONMENT == prod,\n      VERSION \u003e= 1.5\n    true_values: 'service-ok,prod-deploy,new-version'\n    false_values: 'service-fail,no-deploy,old-version'\n\n# Use outputs\n- run: echo \"Service: ${{ steps.checks.outputs.output_1 }}\"\n- run: echo \"Environment: ${{ steps.checks.outputs.output_2 }}\"\n- run: echo \"Version: ${{ steps.checks.outputs.output_3 }}\"\n```\n\n\u003cbr/\u003e\n\n### Example 4: Complex Logic\n\n```yaml\n- uses: somaz94/ternary-operator@v1\n  id: deploy\n  with:\n    conditions: 'SERVICE IN game,api \u0026\u0026 ENVIRONMENT == prod || BRANCH == hotfix'\n    true_values: 'deploy'\n    false_values: 'skip'\n    debug_mode: true\n```\n\n[→ See more examples](docs/usage.md)\n\n\u003cbr/\u003e\n\n## Local Testing\n\nTest your changes before pushing to GitHub:\n\n```bash\n# Run unit tests with pytest (135 tests with coverage)\nmake test\n\n# Run integration tests (42 test cases)\nmake test-local\n\n# Run all tests\nmake test-all\n```\n\nOr without Makefile:\n\n```bash\n# Unit tests (pytest)\npython3 -m pytest tests/ -v --ignore=tests/test_local.py\n\n# Integration tests\npython3 tests/test_local.py\n\n# Bash tests\n./tests/test_local.sh\n```\n\n#### Test Coverage:\n- Unit tests: 135 tests (operators, parser, evaluator, colors)\n- Integration tests: 42 test cases (end-to-end subprocess tests)\n- Bash tests: 17 core tests\n\n[→ See testing guide](docs/development.md#testing)\n\n\u003cbr/\u003e\n\n## Inputs \u0026 Outputs\n\n\u003cbr/\u003e\n\n### Inputs\n\n| Input | Required | Description | Example |\n|-------|----------|-------------|---------|\n| `conditions` | Yes | Comma-separated conditions (max 10) | `SERVICE IN game,batch` |\n| `true_values` | Yes | Values when conditions are true | `deploy,skip` |\n| `false_values` | Yes | Values when conditions are false | `skip,deploy` |\n| `default_values` | No | Fallback values on evaluation error | `fallback1,fallback2` |\n| `case_sensitive` | No | Case-sensitive comparison (default: true) | `false` |\n| `debug_mode` | No | Enable debug logging (default: false) | `true` |\n\n\u003cbr/\u003e\n\n### Outputs\n\n- `output_1` through `output_10` - Results of evaluated conditions\n- `result` - JSON object containing all outputs (e.g. `{\"output_1\": \"value1\", \"output_2\": \"value2\"}`)\n\n[→ See complete API reference](docs/api.md)\n\n\u003cbr/\u003e\n\n## Tips \u0026 Best Practices\n\n1. **Use IN operator** for multiple value checks:\n   ```yaml\n   # Good\n   SERVICE IN game,batch,api\n   \n   # Avoid\n   SERVICE == game || SERVICE == batch || SERVICE == api\n   ```\n\n2. **Keep conditions simple** for readability:\n   ```yaml\n   # Good - split into multiple conditions\n   conditions: 'SERVICE == game, ENVIRONMENT == prod'\n   \n   # Harder to read\n   conditions: 'SERVICE == game \u0026\u0026 ENV == prod \u0026\u0026 BRANCH == main \u0026\u0026 VERSION \u003e= 1.0'\n   ```\n\n3. **Enable debug mode** when troubleshooting:\n   ```yaml\n   debug_mode: true  # Shows detailed evaluation process\n   ```\n\n4. **Test locally** before pushing:\n   ```bash\n   make test-all\n   ```\n\n[→ See more best practices](docs/usage.md)\n\n\u003cbr/\u003e\n\n## Integration\n\nWorks great with:\n- **[env-output-setter](https://github.com/somaz94/env-output-setter)** - Set environment variables and outputs\n- **GitHub Environments** - Environment-specific deployments\n- **Matrix Strategies** - Conditional logic per matrix combination\n\n```yaml\n# Example with env-output-setter\n- name: Set Variables\n  uses: somaz94/env-output-setter@v1\n  with:\n    env_key: 'SERVICE,ENVIRONMENT'\n    env_value: 'game,prod'\n\n- name: Evaluate\n  uses: somaz94/ternary-operator@v1\n  with:\n    conditions: 'SERVICE == game \u0026\u0026 ENVIRONMENT == prod'\n```\n\n[→ See integration examples](docs/usage.md#integration-examples)\n\n\u003cbr/\u003e\n\n## Troubleshooting\n\n#### Common Issues:\n\n\u003cdetails\u003e\n\u003csummary\u003eCondition not evaluating as expected?\u003c/summary\u003e\n\n1. Check variable is set: `echo \"$VARIABLE\" \u003e\u003e $GITHUB_ENV`\n2. Enable debug mode: `debug_mode: true`\n3. Check for case sensitivity: `game` ≠ `Game`\n4. Verify operator syntax: [See operators guide](docs/operators.md)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eArray length mismatch error?\u003c/summary\u003e\n\nEnsure same number of:\n- Conditions\n- True values\n- False values\n\n```yaml\n# Correct - all have 2 items\nconditions: 'A == 1, B == 2'\ntrue_values: 'yes,ok'\nfalse_values: 'no,fail'\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eMaximum conditions exceeded?\u003c/summary\u003e\n\nSplit into multiple action calls or combine with IN operator:\n\n```yaml\n# Instead of 12 individual conditions\nSERVICE == game, SERVICE == batch, ...\n\n# Use IN operator\nSERVICE IN game,batch,...\n```\n\n\u003c/details\u003e\n\n[→ See full troubleshooting guide](docs/troubleshooting.md)\n\n\u003cbr/\u003e\n\n## Contributing\n\nContributions welcome! Please:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/my-feature`\n3. Make your changes\n4. Test locally: `make test-all`\n5. Commit: `git commit -am \"feat: Add new feature\"`\n6. Push and create a Pull Request\n\n[→ See development guide](docs/development.md)\n\n\u003cbr/\u003e\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n\u003cbr/\u003e\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/somaz94/ternary-operator/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/somaz94/ternary-operator/discussions)\n- **Documentation**: [Full Documentation](docs/)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Made for better GitHub Actions workflows**\n\n[Documentation](docs/) | [Examples](docs/usage.md) | [Contributing](docs/development.md)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomaz94%2Fternary-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomaz94%2Fternary-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomaz94%2Fternary-operator/lists"}