perrotuerto.blog/scripts/update.sh

40 lines
808 B
Bash
Raw Permalink Normal View History

2023-06-26 14:26:32 -06:00
DEBUG=false
2023-06-25 16:05:15 -06:00
JSON=public/perro.json
# Va a la raíz del repo
cd $(dirname $0)/..
2023-06-26 13:58:06 -06:00
# Actualiza el repo
2023-06-26 14:26:32 -06:00
if [ $DEBUG = false ]; then
git pull --quiet
fi
2023-06-26 13:58:06 -06:00
2023-06-25 16:05:15 -06:00
# Limpia sitio
2023-06-26 10:29:22 -06:00
if [ -d "public" ]; then rm -rf public; fi
2023-06-25 16:05:15 -06:00
mkdir public
cp -r src/* public
rm public/*.*
2023-10-01 10:44:46 -06:00
# Descarga info de linkding
2023-06-25 16:05:15 -06:00
curl --request GET \
-s -o $JSON \
-H "Authorization: Token $(<.token)" \
"https://linkding.cuates.net/api/bookmarks/?q=%23blog"
2023-10-01 10:44:46 -06:00
if [ "$?" != 0 ]; then exit 1; fi
2023-06-25 16:05:15 -06:00
# Rehace sitio y JSON
python3 ./scripts/make.py $JSON
# Hace commit al repo si hubo cambios
2023-06-26 14:26:32 -06:00
if [ $DEBUG = false ] && [ -n "$(git status --porcelain)" ]; then
2023-06-26 13:35:10 -06:00
git add .
git commit -m "Actualización"
2023-08-21 01:00:05 -06:00
git push -q origin
git push -q cuates
git log -1 --name-only --oneline | cat
2023-06-26 13:35:10 -06:00
fi
2023-06-26 14:26:32 -06:00
# Limpia variables
unset DEBUG
unset JSON