working out the worker/execution interface
This commit is contained in:
@@ -1,31 +1,77 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# No Operation Action - Core Pack
|
||||
# Does nothing - useful for testing and placeholder workflows
|
||||
#
|
||||
# This script uses pure POSIX shell without external dependencies like jq or yq.
|
||||
# It reads parameters in DOTENV format from stdin until the delimiter.
|
||||
|
||||
set -e
|
||||
|
||||
# Parse parameters from environment variables
|
||||
MESSAGE="${ATTUNE_ACTION_MESSAGE:-}"
|
||||
EXIT_CODE="${ATTUNE_ACTION_EXIT_CODE:-0}"
|
||||
# Initialize variables
|
||||
message=""
|
||||
exit_code="0"
|
||||
|
||||
# Validate exit code parameter
|
||||
if ! [[ "$EXIT_CODE" =~ ^[0-9]+$ ]]; then
|
||||
echo "ERROR: exit_code must be a positive integer" >&2
|
||||
exit 1
|
||||
fi
|
||||
# Read DOTENV-formatted parameters from stdin until delimiter
|
||||
while IFS= read -r line; do
|
||||
# Check for parameter delimiter
|
||||
case "$line" in
|
||||
*"---ATTUNE_PARAMS_END---"*)
|
||||
break
|
||||
;;
|
||||
message=*)
|
||||
# Extract value after message=
|
||||
message="${line#message=}"
|
||||
# Remove quotes if present (both single and double)
|
||||
case "$message" in
|
||||
\"*\")
|
||||
message="${message#\"}"
|
||||
message="${message%\"}"
|
||||
;;
|
||||
\'*\')
|
||||
message="${message#\'}"
|
||||
message="${message%\'}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
exit_code=*)
|
||||
# Extract value after exit_code=
|
||||
exit_code="${line#exit_code=}"
|
||||
# Remove quotes if present
|
||||
case "$exit_code" in
|
||||
\"*\")
|
||||
exit_code="${exit_code#\"}"
|
||||
exit_code="${exit_code%\"}"
|
||||
;;
|
||||
\'*\')
|
||||
exit_code="${exit_code#\'}"
|
||||
exit_code="${exit_code%\'}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$EXIT_CODE" -lt 0 ] || [ "$EXIT_CODE" -gt 255 ]; then
|
||||
# Validate exit code parameter (must be numeric)
|
||||
case "$exit_code" in
|
||||
''|*[!0-9]*)
|
||||
echo "ERROR: exit_code must be a positive integer" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Validate exit code range (0-255)
|
||||
if [ "$exit_code" -lt 0 ] || [ "$exit_code" -gt 255 ]; then
|
||||
echo "ERROR: exit_code must be between 0 and 255" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Log message if provided
|
||||
if [ -n "$MESSAGE" ]; then
|
||||
echo "[NOOP] $MESSAGE"
|
||||
if [ -n "$message" ]; then
|
||||
echo "[NOOP] $message"
|
||||
fi
|
||||
|
||||
# Output result
|
||||
echo "No operation completed successfully"
|
||||
|
||||
# Exit with specified code
|
||||
exit "$EXIT_CODE"
|
||||
exit "$exit_code"
|
||||
|
||||
Reference in New Issue
Block a user