feat: will now only update teh links if they change, or if an override is passed

This commit is contained in:
silver 2023-12-27 22:49:39 +00:00
parent 1057bae86e
commit 08144baa42
3 changed files with 21 additions and 2 deletions

View file

@ -48,6 +48,7 @@ sync_repos:
- chmod +x ./sync.sh
- ./sync.sh
rules:
- if: '$SYNC_OVERRIDE == "true"'
- changes:
- sync/repos.csv

2
sync/.gitignore vendored
View file

@ -1,2 +1,4 @@
/.idea
.env
repos_active.csv
repos_diff.csv

View file

@ -1,5 +1,13 @@
#!/bin/bash
Get-Existing(){
curl -s "https://gitlab.skynet.ie/compsoc1/skynet/nixos/-/raw/main/sync/repos.csv" -o "./repos_active.csv"
}
Get-Diff(){
diff --changed-group-format='%<' --unchanged-group-format='' repos.csv repos_active.csv > repos_diff.csv
}
Mirror-Clear(){
# existing remotes
local id=$(tr -d '\n\t\r ' <<<"${1}" )
@ -35,11 +43,19 @@ Main() {
# for local dev
source .env
# if SYNC_OVERRIDE is not set then
if [ -z "${SYNC_OVERRIDE}" ]; then
Get-Existing
Get-Diff
else
cp repos.csv repos_diff.csv
fi
while IFS="," read -r id remote
do
Mirror-Clear $id
Mirror-Create $id $remote
done < <(tail -n +2 ./repos.csv)
done < <(tail -n +2 ./repos_diff.csv)
}
Main