eolas/scripts/auto_save.sh

48 lines
1.3 KiB
Bash
Raw Normal View History

2022-12-07 07:30:05 +00:00
#!/bin/bash
2024-10-21 13:00:01 +01:00
#============================================================================#
# FILE: auto_save.sh #
# USAGE: auto_save.sh #
# DESCRIPTION: Automatically pulls and commits changes to remote after: #
# running cleanup scripts #
# generating Neuron zettelkasten static site and writing to neuron/ #
#============================================================================#
2022-12-07 07:30:05 +00:00
2024-03-14 17:30:04 +00:00
USER=thomas
export XDG_RUNTIME_DIR=/run/user/1000
2024-04-14 21:50:03 +01:00
source /home/thomas/.env
2024-03-01 09:00:21 +00:00
tidy_filenames="/home/thomas/repos/eolas/scripts/tidy_filenames.sh"
2024-10-21 13:00:01 +01:00
# purge_images="/home/thomas/repos/eolas/scripts/purge_images.sh"
2023-01-21 12:18:17 +00:00
2024-03-01 09:01:19 +00:00
cd /home/thomas/repos/eolas
2022-12-07 07:30:05 +00:00
2024-02-29 18:50:36 +00:00
echo "Standardising file-names..."
2024-02-25 19:38:14 +00:00
source ${tidy_filenames}
2024-10-19 12:40:43 +01:00
# echo "Removing unused images..."
# source ${purge_images}
2023-01-21 13:06:01 +00:00
echo "Checking for changes..."
2023-01-21 13:50:33 +00:00
git pull >/dev/null 2>&1
2023-01-21 13:07:01 +00:00
2023-02-21 07:39:26 +00:00
changes_exist="$(git status --porcelain | wc -l)"
2022-12-07 07:30:05 +00:00
# If no changes, exit. Else commit and push with timestamp
2023-02-21 07:39:26 +00:00
if [ "$changes_exist" -eq 0 ]; then
2024-03-27 17:03:19 +00:00
echo "No changes, exiting"
2022-12-07 07:30:05 +00:00
exit 0
fi
2024-02-26 19:10:38 +00:00
echo "Changes exist. Updating remote..."
2023-01-21 13:50:33 +00:00
git pull >/dev/null 2>&1
2022-12-07 07:30:05 +00:00
git add .
2022-12-09 08:30:05 +00:00
git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")"
2023-01-21 13:51:23 +00:00
git push
2024-03-05 18:20:03 +00:00
2024-10-19 12:40:43 +01:00
/home/thomas/repos/neuron-zk-generator/dist/app
2024-10-19 12:00:05 +01:00
/home/thomas/repos/slack-notifier/src/index.js 'eolas' '✅ Eolas: auto-save executed'
2024-04-14 18:00:04 +01:00