Skip to content

Commit

Permalink
fix: remove old report
Browse files Browse the repository at this point in the history
  • Loading branch information
firmansyahrosid committed Jul 29, 2024
1 parent 3943d6a commit 156ffe1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi

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

# Determine which folders to keep based on INPUT_KEEP_REPORTS
echo "Keep reports count ${INPUT_KEEP_REPORTS}"
Expand All @@ -38,9 +38,18 @@ if [[ "${INPUT_REPORT_FOLDER}" == *"allure-results"* ]]; then
if ((COUNT > INPUT_KEEP_REPORTS)); then
cd ./${INPUT_REPORT_HISTORY}
echo "Remove index.html last-history"
rm index.html last-history -rv
echo "Remove old reports"
ls | sort -n | head -n -$((${INPUT_KEEP_REPORTS}-2)) | xargs rm -rv;
rm -rv index.html last-history
# Calculate the number of files to delete
num_files_to_keep=$((${INPUT_KEEP_REPORTS} - 2))
num_files=$(ls | wc -l)
num_files_to_delete=$(($num_files - $num_files_to_keep))
# Check if there are any files to delete
if [ "$num_files_to_delete" -gt 0 ]; then
echo "Remove old reports"
ls | sort -n | head -n "$num_files_to_delete" | xargs rm -rv
else
echo "No files to delete."
fi
cd ${GITHUB_WORKSPACE}
fi

Expand Down

0 comments on commit 156ffe1

Please sign in to comment.