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 - chmod +x ./sync.sh
- ./sync.sh - ./sync.sh
rules: rules:
- if: '$SYNC_OVERRIDE == "true"'
- changes: - changes:
- sync/repos.csv - sync/repos.csv

4
sync/.gitignore vendored
View file

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

View file

@ -1,5 +1,13 @@
#!/bin/bash #!/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(){ Mirror-Clear(){
# existing remotes # existing remotes
local id=$(tr -d '\n\t\r ' <<<"${1}" ) local id=$(tr -d '\n\t\r ' <<<"${1}" )
@ -35,11 +43,19 @@ Main() {
# for local dev # for local dev
source .env 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 while IFS="," read -r id remote
do do
Mirror-Clear $id Mirror-Clear $id
Mirror-Create $id $remote Mirror-Create $id $remote
done < <(tail -n +2 ./repos.csv) done < <(tail -n +2 ./repos_diff.csv)
} }
Main Main