build-pdf: only build changed folders since last commit

pull/23/head
Sebastiaan Speck 2023-12-17 15:18:19 +01:00 committed by K.B.Dharun Krishna
parent ad11098280
commit f907fcbb2f
1 changed files with 18 additions and 4 deletions

22
scripts/pdf/build-pdf.sh Normal file → Executable file
View File

@ -21,13 +21,27 @@ function process_page {
}
function main {
for pageDir in ../../pages*; do
process_page "${pageDir}"
done
type="$1"
case $type in
"all")
for pageDir in ../../pages*; do
process_page "${pageDir}"
done
;;
*)
changedFiles=$(git diff-tree --no-commit-id --name-only -r "$(git rev-parse HEAD)")
changedPageDirs=$(echo "$changedFiles" | awk -F/ '/^(pages[^\/]+|pages)\//{print $1}' | sort -u)
mapfile -t pageDirs <<< "$changedPageDirs"
for pageDir in "${pageDirs[@]}"; do
process_page "../../${pageDir}"
done
;;
esac
}
###################################
# MAIN
###################################
main
main $1