feat: will now only update teh links if they change, or if an override is passed
This commit is contained in:
parent
1057bae86e
commit
08144baa42
3 changed files with 21 additions and 2 deletions
|
@ -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
2
sync/.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
/.idea
|
||||
.env
|
||||
repos_active.csv
|
||||
repos_diff.csv
|
18
sync/sync.sh
18
sync/sync.sh
|
@ -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
|
Loading…
Reference in a new issue