Skip to content

Commit 156ffe1

Browse files
fix: remove old report
1 parent 3943d6a commit 156ffe1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

generate.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fi
2626

2727
# Removing the folder with the smallest number
2828
COUNT=$( (ls ./${INPUT_REPORT_HISTORY} | wc -l))
29-
echo "Count folders in report-history: ${COUNT}"
29+
echo "Count folders in ${INPUT_REPORT_HISTORY}: ${COUNT}"
3030

3131
# Determine which folders to keep based on INPUT_KEEP_REPORTS
3232
echo "Keep reports count ${INPUT_KEEP_REPORTS}"
@@ -38,9 +38,18 @@ if [[ "${INPUT_REPORT_FOLDER}" == *"allure-results"* ]]; then
3838
if ((COUNT > INPUT_KEEP_REPORTS)); then
3939
cd ./${INPUT_REPORT_HISTORY}
4040
echo "Remove index.html last-history"
41-
rm index.html last-history -rv
42-
echo "Remove old reports"
43-
ls | sort -n | head -n -$((${INPUT_KEEP_REPORTS}-2)) | xargs rm -rv;
41+
rm -rv index.html last-history
42+
# Calculate the number of files to delete
43+
num_files_to_keep=$((${INPUT_KEEP_REPORTS} - 2))
44+
num_files=$(ls | wc -l)
45+
num_files_to_delete=$(($num_files - $num_files_to_keep))
46+
# Check if there are any files to delete
47+
if [ "$num_files_to_delete" -gt 0 ]; then
48+
echo "Remove old reports"
49+
ls | sort -n | head -n "$num_files_to_delete" | xargs rm -rv
50+
else
51+
echo "No files to delete."
52+
fi
4453
cd ${GITHUB_WORKSPACE}
4554
fi
4655

0 commit comments

Comments
 (0)