Commit 2d97b71c authored by nanahira's avatar nanahira

add change detector

parent 59debdb4
Pipeline #33687 passed with stages
in 51 seconds
......@@ -3,7 +3,7 @@
echo "Cleaning up workspace and dist directories"
rm -rf workspace dist || true
mkdir -p workspace dist/redtexts dist/pics dist/script
mkdir -p workspace dist/redtexts dist/pics dist/script dist/hashes
echo '# Auto generated by ygopro-custom-free' > dist/strings.conf
# YGOPRO_SERVER_PATH="/home/nanahira/ygo/srvpro/ygopro"
......@@ -12,6 +12,7 @@ echo '# Auto generated by ygopro-custom-free' > dist/strings.conf
CURRENT_TIME=$(date +%s)
something_changed=0
process_repo() {
repo_url="$1"
......@@ -46,6 +47,7 @@ process_repo() {
# check last commit date
cd "workspace/$repo_identifer"
last_commit_timestamp="$(git log -1 --format="%cd" --date=format:'%s')"
last_commit_hash="$(git log -1 --format="%H")"
echo "Checking last commit date of $repo_identifer: $(git log -1 --format="%cd")"
cd "$current_path"
......@@ -54,8 +56,13 @@ process_repo() {
return
fi
echo "Checking for redtexts in $repo_identifer"
# fetch previous hash
previous_hash=$(curl -sL "https://cdn02.moecube.com:444/ygopro-custom-free/contents/hashes/$repo_identifer.txt" || true)
if [[ $previous_hash != $last_commit_hash ]]; then
something_changed=1
fi
echo "Checking for redtexts in $repo_identifer"
cd "$YGOPRO_SERVER_PATH"
rm expansions || rmdir expansions || true
......@@ -85,6 +92,7 @@ process_repo() {
fi
cp -rf workspace/$repo_identifer/pics dist/
cp -rf workspace/$repo_identifer/script dist/
echo "$last_commit_hash" > dist/hashes/$repo_identifer.txt
echo "Finished processing $repo_identifer"
}
......@@ -97,5 +105,10 @@ for file in repos/*.txt; do
done < "$file"
done
if [[ $something_changed == 0 ]]; then
echo "No changes detected, skipping update"
exit 1
fi
echo "Finished processing all repos"
echo "YGOPro Custom Free Server - Updated at $(date)" > dist/version.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment