[WIP] Workflows
This commit is contained in:
@@ -1,17 +1,58 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# List Example Action
|
||||
# Demonstrates JSON Lines output format for streaming results
|
||||
#
|
||||
# This script uses pure POSIX shell without external dependencies like jq.
|
||||
# It reads parameters in DOTENV format from stdin until the delimiter.
|
||||
|
||||
set -euo pipefail
|
||||
set -e
|
||||
|
||||
# Read parameters from stdin (JSON format)
|
||||
read -r params_json
|
||||
# Initialize count with default
|
||||
count=5
|
||||
|
||||
# Extract count parameter (default to 5 if not provided)
|
||||
count=$(echo "$params_json" | jq -r '.count // 5')
|
||||
# Read DOTENV-formatted parameters from stdin until delimiter
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
*"---ATTUNE_PARAMS_END---"*)
|
||||
break
|
||||
;;
|
||||
count=*)
|
||||
# Extract value after count=
|
||||
count="${line#count=}"
|
||||
# Remove quotes if present (both single and double)
|
||||
case "$count" in
|
||||
\"*\")
|
||||
count="${count#\"}"
|
||||
count="${count%\"}"
|
||||
;;
|
||||
\'*\')
|
||||
count="${count#\'}"
|
||||
count="${count%\'}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Validate count is a positive integer
|
||||
case "$count" in
|
||||
''|*[!0-9]*)
|
||||
count=5
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$count" -lt 1 ]; then
|
||||
count=1
|
||||
elif [ "$count" -gt 100 ]; then
|
||||
count=100
|
||||
fi
|
||||
|
||||
# Generate JSON Lines output (one JSON object per line)
|
||||
for i in $(seq 1 "$count"); do
|
||||
i=1
|
||||
while [ "$i" -le "$count" ]; do
|
||||
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
echo "{\"id\": $i, \"value\": \"item_$i\", \"timestamp\": \"$timestamp\"}"
|
||||
printf '{"id": %d, "value": "item_%d", "timestamp": "%s"}\n' "$i" "$i" "$timestamp"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -12,9 +12,9 @@ runner_type: shell
|
||||
# Entry point is the shell script to execute
|
||||
entry_point: list_example.sh
|
||||
|
||||
# Parameter delivery: stdin for secure parameter passing
|
||||
# Parameter delivery: stdin for secure parameter passing (no env vars)
|
||||
parameter_delivery: stdin
|
||||
parameter_format: json
|
||||
parameter_format: dotenv
|
||||
|
||||
# Output format: jsonl (each line is a JSON object, collected into array)
|
||||
output_format: jsonl
|
||||
|
||||
Reference in New Issue
Block a user