File tree Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Expand file tree Collapse file tree 1 file changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -35,12 +35,32 @@ jobs:
3535
3636 - name : Read PR Number
3737 run : |
38- PR_NUMBER=$(cat pr_number/pr_number.txt | grep -E '^[0-9]+$')
39- if [ -z "$PR_NUMBER" ]; then
40- echo "Error: PR_NUMBER is not a valid integer."
38+ set -Eeuo pipefail
39+ FILE='pr_number/pr_number.txt'
40+
41+ # Ensure file exists
42+ if [ ! -f "$FILE" ] || [ -L "$FILE" ]; then
43+ echo "Error: $FILE is missing or is not a regular file." >&2
4144 exit 1
4245 fi
43- echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
46+
47+ # Chec file size
48+ if [ "$(wc -c < "$FILE" | tr -d ' ')" -gt 200 ]; then
49+ echo "Error: $FILE is too large." >&2
50+ exit 1
51+ fi
52+
53+ # Read first line
54+ PR_NUMBER=""
55+ IFS= read -r PR_NUMBER < "$FILE" || true
56+
57+ # Validate whether it's a number
58+ if ! [[ "$PR_NUMBER" =~ ^[0-9]{1,10}$ ]]; then
59+ echo "Error: PR_NUMBER is not a valid integer on the first line." >&2
60+ exit 1
61+ fi
62+
63+ printf 'PR_NUMBER=%s\n' "$PR_NUMBER" >> "$GITHUB_ENV"
4464
4565 - name : Post PR Comment
4666 uses : ctrf-io/github-test-reporter@v1
You can’t perform that action at this time.
0 commit comments