fix: support INPUT_ACTION_TYPE and INPUT_ACTION (#305)

This commit is contained in:
2025-10-24 15:55:09 +03:00
committed by GitHub
parent a3fb0bd8db
commit 2d8ff47548
4 changed files with 16 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ Centralized Python-based input validation for GitHub Actions with PCRE regex sup
| name | description | required | default |
|---------------------|------------------------------------------------------------------------------------|----------|---------|
| `action` | <p>Action name to validate (alias for action-type)</p> | `true` | `""` |
| `action` | <p>Action name to validate (alias for action-type)</p> | `false` | `""` |
| `action-type` | <p>Type of action to validate (e.g., csharp-publish, docker-build, eslint-fix)</p> | `false` | `""` |
| `rules-file` | <p>Path to validation rules file</p> | `false` | `""` |
| `fail-on-error` | <p>Whether to fail on validation errors</p> | `false` | `true` |
@@ -81,7 +81,7 @@ This action is a `composite` action.
action:
# Action name to validate (alias for action-type)
#
# Required: true
# Required: false
# Default: ""
action-type:

View File

@@ -13,7 +13,7 @@ branding:
inputs:
action:
description: 'Action name to validate (alias for action-type)'
required: true
required: false
action-type:
description: 'Type of action to validate (e.g., csharp-publish, docker-build, eslint-fix)'
required: false

View File

@@ -32,7 +32,7 @@ def collect_inputs() -> dict[str, str]:
"""
inputs = {}
for key, value in os.environ.items():
if key.startswith("INPUT_") and key != "INPUT_ACTION_TYPE":
if key.startswith("INPUT_") and key not in ("INPUT_ACTION_TYPE", "INPUT_ACTION"):
input_name = key[6:].lower()
inputs[input_name] = value
@@ -73,8 +73,11 @@ def write_output(status: str, action_type: str, **kwargs) -> None:
def main() -> None:
"""Main validation entry point."""
# Get the action type from environment
action_type = os.environ.get("INPUT_ACTION_TYPE", "").strip()
# Get the action type from environment (check both INPUT_ACTION_TYPE and INPUT_ACTION)
action_type = (
os.environ.get("INPUT_ACTION_TYPE", "").strip()
or os.environ.get("INPUT_ACTION", "").strip()
)
if not action_type:
logger.error("::error::No action type provided")
sys.exit(1)