-
-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Clean Repository | ||
|
||
inputs: | ||
target: | ||
required: true | ||
type: string | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Git Clean | ||
shell: bash | ||
run: | | ||
git clean -ffdx -e node_modules target | ||
git reset --hard HEAD | ||
- name: Clean Large Directories by Size | ||
if: ${{ !contains(inputs.target, 'windows') }} | ||
shell: bash | ||
run: | | ||
if [ -d "target" ]; then | ||
TARGET_SIZE=$(du -s target | awk '{print $1}') | ||
MAX_SIZE=$((50 * 1024 * 1024)) | ||
echo "MAX_SIZE = $MAX_SIZE" | ||
if [ "$TARGET_SIZE" -gt "$MAX_SIZE" ]; then | ||
echo "`target` directory size is greater than 50GB, deleting..." | ||
rm -rf target | ||
else | ||
echo "`target` directory size is within limits." | ||
fi | ||
fi | ||
if [ -d "node\_modules" ]; then | ||
NODE_MODULES_SIZE=$(du -s node_modules | awk '{print $1}') | ||
MAX_SIZE=$((50 * 1024 * 1024)) | ||
echo "MAX_SIZE = $MAX_SIZE" | ||
if [ "$NODE_MODULES_SIZE" -gt "$MAX_SIZE" ]; then | ||
echo "`node_modules` directory size is greater than 50GB, deleting..." | ||
rm -rf node_modules | ||
else | ||
echo "`node_modules` directory size is within limits." | ||
fi | ||
fi | ||
- name: Clean Large Directories by Time | ||
if: ${{ contains(inputs.target, 'windows') }} | ||
shell: bash | ||
run: | | ||
if [ -d "target" ]; then | ||
TARGET_CREATION_TIME=$(powershell -Command "(Get-Item 'target').CreationTime") | ||
TWO_WEEKS_AGO=$(date -d '2 weeks ago' +%s) | ||
echo "TARGET_CREATION_TIME = $TARGET_CREATION_TIME" | ||
if [ "$TARGET_CREATION_TIME" -lt "$TWO_WEEKS_AGO" ]; then | ||
echo "'target' directory is older than 2 weeks, deleting..." | ||
rm -rf target | ||
else | ||
echo "'target' directory is within 2 weeks." | ||
fi | ||
fi | ||
if [ -d "node\_modules" ]; then | ||
NODE_MODULES_CREATION_TIME=$(powershell -Command "(Get-Item 'target').CreationTime") | ||
ONE_MONTH_AGO=$(date -d '1 month ago' +%s) | ||
echo "NODE_MODULES_CREATION_TIME = $NODE_MODULES_CREATION_TIME" | ||
if [ "$NODE_MODULES_CREATION_TIME" -lt "$ONE_MONTH_AGO" ]; then | ||
echo "'node_modules' directory is older than 1 month, deleting..." | ||
rm -rf node_modules | ||
else | ||
echo "'node_modules' directory is within 1 month." | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters