mirror of
https://github.com/appleboy/ssh-action.git
synced 2026-02-23 11:36:23 +08:00
ci: enforce unique occurrence of lines in multiline output validation
- Add a step to verify that lines "Line 1", "Line 2", and "Line 3" each appear exactly once in the multiline output - Fail the workflow if any line is missing or duplicated - Confirm successful validation with a message when no duplicates are found Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
parent
328b174987
commit
353036a24e
25
.github/workflows/main.yml
vendored
25
.github/workflows/main.yml
vendored
@ -653,6 +653,31 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for duplicates - each unique line should appear exactly once
|
||||||
|
OUTPUT="${{ steps.stdout-multiline.outputs.stdout }}"
|
||||||
|
LINE1_COUNT=$(echo "$OUTPUT" | grep -c "^Line 1$" || true)
|
||||||
|
LINE2_COUNT=$(echo "$OUTPUT" | grep -c "^Line 2$" || true)
|
||||||
|
LINE3_COUNT=$(echo "$OUTPUT" | grep -c "^Line 3$" || true)
|
||||||
|
|
||||||
|
echo "Line 1 count: $LINE1_COUNT"
|
||||||
|
echo "Line 2 count: $LINE2_COUNT"
|
||||||
|
echo "Line 3 count: $LINE3_COUNT"
|
||||||
|
|
||||||
|
if [ "$LINE1_COUNT" -ne 1 ]; then
|
||||||
|
echo "Error: 'Line 1' appears $LINE1_COUNT times (expected 1)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$LINE2_COUNT" -ne 1 ]; then
|
||||||
|
echo "Error: 'Line 2' appears $LINE2_COUNT times (expected 1)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$LINE3_COUNT" -ne 1 ]; then
|
||||||
|
echo "Error: 'Line 3' appears $LINE3_COUNT times (expected 1)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✓ No duplicate lines detected"
|
||||||
|
|
||||||
- id: stdout-with-special-chars
|
- id: stdout-with-special-chars
|
||||||
name: capture output with special characters
|
name: capture output with special characters
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user