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 @@ ...@@ -3,7 +3,7 @@
echo "Cleaning up workspace and dist directories" echo "Cleaning up workspace and dist directories"
rm -rf workspace dist || true 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 echo '# Auto generated by ygopro-custom-free' > dist/strings.conf
# YGOPRO_SERVER_PATH="/home/nanahira/ygo/srvpro/ygopro" # YGOPRO_SERVER_PATH="/home/nanahira/ygo/srvpro/ygopro"
...@@ -12,6 +12,7 @@ echo '# Auto generated by ygopro-custom-free' > dist/strings.conf ...@@ -12,6 +12,7 @@ echo '# Auto generated by ygopro-custom-free' > dist/strings.conf
CURRENT_TIME=$(date +%s) CURRENT_TIME=$(date +%s)
something_changed=0
process_repo() { process_repo() {
repo_url="$1" repo_url="$1"
...@@ -46,6 +47,7 @@ process_repo() { ...@@ -46,6 +47,7 @@ process_repo() {
# check last commit date # check last commit date
cd "workspace/$repo_identifer" cd "workspace/$repo_identifer"
last_commit_timestamp="$(git log -1 --format="%cd" --date=format:'%s')" 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")" echo "Checking last commit date of $repo_identifer: $(git log -1 --format="%cd")"
cd "$current_path" cd "$current_path"
...@@ -54,8 +56,13 @@ process_repo() { ...@@ -54,8 +56,13 @@ process_repo() {
return return
fi 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" cd "$YGOPRO_SERVER_PATH"
rm expansions || rmdir expansions || true rm expansions || rmdir expansions || true
...@@ -85,6 +92,7 @@ process_repo() { ...@@ -85,6 +92,7 @@ process_repo() {
fi fi
cp -rf workspace/$repo_identifer/pics dist/ cp -rf workspace/$repo_identifer/pics dist/
cp -rf workspace/$repo_identifer/script dist/ cp -rf workspace/$repo_identifer/script dist/
echo "$last_commit_hash" > dist/hashes/$repo_identifer.txt
echo "Finished processing $repo_identifer" echo "Finished processing $repo_identifer"
} }
...@@ -97,5 +105,10 @@ for file in repos/*.txt; do ...@@ -97,5 +105,10 @@ for file in repos/*.txt; do
done < "$file" done < "$file"
done done
if [[ $something_changed == 0 ]]; then
echo "No changes detected, skipping update"
exit 1
fi
echo "Finished processing all repos" echo "Finished processing all repos"
echo "YGOPro Custom Free Server - Updated at $(date)" > dist/version.txt 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