File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 2626
2727# Removing the folder with the smallest number
2828COUNT=$( (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
3232echo " 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
You can’t perform that action at this time.
0 commit comments