File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 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
615BUILD_TIME=" $1 "
716TOTAL_TIME=" $2 "
@@ -10,6 +19,20 @@ FAILED="$4"
1019RUN_ID=" $5 "
1120COMPARISON_SECTION=" $6 "
1221REPO=" $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
1538convert_time () {
@@ -30,7 +53,7 @@ This PR has been automatically created after successful completion of all CI sta
3053\`\`\`
3154EOF
3255
33- cat /tmp/commit_message.txt
56+ cat " $COMMIT_MESSAGE_FILE "
3457
3558cat << EOF
3659\`\`\`
You can’t perform that action at this time.
0 commit comments