Skip to content

Commit 1527029

Browse files
Minor fixes 2
Signed-off-by: Shreeya Patel <[email protected]>
1 parent 58d4b17 commit 1527029

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

.github/scripts/create-pr-body.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
#!/bin/bash
22

33
# Script to create PR body
4-
# Arguments: build_time total_time passed failed run_id comparison_section
4+
# Arguments: build_time total_time passed failed run_id comparison_section repo commit_message_file
5+
6+
set -euo pipefail
7+
8+
# Check number of arguments
9+
if [ $# -lt 7 ] || [ $# -gt 8 ]; then
10+
echo "Error: Expected 7 or 8 arguments, got $#" >&2
11+
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
12+
exit 1
13+
fi
514

615
BUILD_TIME="$1"
716
TOTAL_TIME="$2"
@@ -10,6 +19,20 @@ FAILED="$4"
1019
RUN_ID="$5"
1120
COMPARISON_SECTION="$6"
1221
REPO="$7"
22+
COMMIT_MESSAGE_FILE="${8:-/tmp/commit_message.txt}"
23+
24+
# Validate required arguments are not empty
25+
if [ -z "$BUILD_TIME" ] || [ -z "$TOTAL_TIME" ] || [ -z "$PASSED" ] || [ -z "$FAILED" ] || [ -z "$RUN_ID" ] || [ -z "$COMPARISON_SECTION" ] || [ -z "$REPO" ]; then
26+
echo "Error: One or more required arguments are empty" >&2
27+
echo "Usage: $0 <build_time> <total_time> <passed> <failed> <run_id> <comparison_section> <repo> [commit_message_file]" >&2
28+
exit 1
29+
fi
30+
31+
# Check if commit message file exists
32+
if [ ! -f "$COMMIT_MESSAGE_FILE" ]; then
33+
echo "Error: Commit message file not found: $COMMIT_MESSAGE_FILE" >&2
34+
exit 1
35+
fi
1336

1437
# Convert seconds to minutes for better readability
1538
convert_time() {
@@ -30,7 +53,7 @@ This PR has been automatically created after successful completion of all CI sta
3053
\`\`\`
3154
EOF
3255

33-
cat /tmp/commit_message.txt
56+
cat "$COMMIT_MESSAGE_FILE"
3457

3558
cat << EOF
3659
\`\`\`

0 commit comments

Comments
 (0)