Update cron-job.sh
Browse files- cron-job.sh +12 -9
cron-job.sh
CHANGED
|
@@ -12,12 +12,15 @@ echo "$(date): Starting cron job" >> $LOG_FILE
|
|
| 12 |
echo "$(date): Pulling latest changes from repository" >> $LOG_FILE
|
| 13 |
git -C $TARGET_DIR pull $REPO_URL >> $LOG_FILE 2>&1
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
echo "$(date): Pulling latest changes from repository" >> $LOG_FILE
|
| 13 |
git -C $TARGET_DIR pull $REPO_URL >> $LOG_FILE 2>&1
|
| 14 |
|
| 15 |
+
while true; do
|
| 16 |
+
# Check if there are changes to commit
|
| 17 |
+
if [[ -n $(git -C $TARGET_DIR status -s) ]]; then
|
| 18 |
+
echo "$(date): Changes detected, committing changes" >> $LOG_FILE
|
| 19 |
+
git -C $TARGET_DIR add . >> $LOG_FILE 2>&1
|
| 20 |
+
git -C $TARGET_DIR commit -m "Automated commit of changes" >> $LOG_FILE 2>&1
|
| 21 |
+
git -C $TARGET_DIR push $REPO_URL >> $LOG_FILE 2>&1
|
| 22 |
+
else
|
| 23 |
+
echo "$(date): No changes detected" >> $LOG_FILE
|
| 24 |
+
fi
|
| 25 |
+
sleep 60
|
| 26 |
+
done
|