-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache fetched submodules across jobs
Saves storage and bandwidth by cloning the submodules only once per workflow run. I also do some small steps to reduce the size of checked out repos so that the size of the cache is reduced. Signed-off-by: Nick Kossifidis <[email protected]>
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 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,25 @@ | ||
#!/bin/bash | ||
|
||
function deduplicate_files() { | ||
local DUPLICATES=() | ||
local DIR=${1} | ||
local OLDIFS=${IFS} | ||
local LINK_CHECK="" | ||
|
||
readarray -t DUPLICATES < <(for i in `find ${DIR} -type f ! -empty`; do sha1sum ${i}; done | sort | uniq -w 40 --all-repeated=separate) | ||
|
||
for ((i=1; i < ${#DUPLICATES[@]}; i++ )); do | ||
if [[ ${DUPLICATES[$i]} == "" ]]; then | ||
continue | ||
elif [[ ${DUPLICATES[$i-1]} = "" ]]; then | ||
continue | ||
else | ||
LINK_CHECK=$(ls -li "${DUPLICATES[$i]:42}" "${DUPLICATES[$i-1]:42}" |awk '{print $1}' | uniq | wc -l) | ||
if [[ ${LINK_CHECK} != "1" ]]; then | ||
ln -f "${DUPLICATES[$i-1]:42}" "${DUPLICATES[$i]:42}" | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
deduplicate_files ${1} |
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