-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-pull-add-commit-push.sh
48 lines (39 loc) · 1.34 KB
/
git-pull-add-commit-push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
v_date=$(date +%I:%M" "%p" "%Z" "%d-%m-%Y)
v_hostname=$(hostname -f)
{
echo -e "\nExecution of : $(pwd)/$(basename $0)"
echo -e "\nFrom Host : ${v_hostname}"
} > logs-git-pull-add-commit-push.txt
if ! ping -c 1 github.com &>/dev/null
then
{
echo -e "\nInternet is Down! Execution stopped !\n"
echo -e "Time of Execution : $v_date \n"
} &> logs-git-pull-add-commit-push.txt
cat logs-git-pull-add-commit-push.txt
exit
fi
{
echo -e "\nScript execution started at : $(date) . . ."
echo -e "\nPulling changes from GitHub . . .\n"
git pull
echo -e "\nStaging changes of local repository $(pwd) . . .\n"
git add .
echo -e "\nCommitting changes . . .\n"
git commit -m "Commit from ${v_hostname} on $v_date"
echo -e "\nPushing changes to GitHub . . .\n"
git push
echo -e "\nPushing changes to GitLab . . .\n"
git push origin-gitlab main
echo -e "\nPublic Code Repository details :\n"
echo -e "GitHub:"
echo -e " HTTPS : https://github.com/Muthukumar-Subramaniam/pub.git"
echo -e " SSH : git@github.com:Muthukumar-Subramaniam/pub.git"
echo -e "\nGitLab:"
echo -e " HTTPS : https://gitlab.com/muthukumar-gitlab/pub.git"
echo -e " SSH : git@gitlab.com:muthukumar-gitlab/pub.git"
v_date=$(date +%I:%M" "%p" "%Z" "%d-%m-%Y)
echo -e "\nScript execution completed at : $(date) .\n"
} &>> logs-git-pull-add-commit-push.txt
cat logs-git-pull-add-commit-push.txt