33# ## @Author : Luke Penrod - support@deepinthought.io
44# ## @Company : DeepInThought
55# ## @Link : https://deepinthought.io
6- # ## @Date : Saturday,September 29 2018 11:26:22
6+ # ## @Created : Saturday,September 29 2018 11:26:22
7+ # ## @Modified : Saturday,September 29 2018 15:21:16
78# ##-
89
10+
911echo -e " \\ 033[0;32mDeploying updates to GitHub...\\ 033[0m"
1012export ROOT_PATH=" ${HOME} /Documents"
1113export GIT_LOCAL_PATH=" ${ROOT_PATH} /vscode-shell-snippets"
1214export GIT_REPOSITORY=" https://github.com/DeepInThought/vscode-shell-snippets.git"
1315export GIT_RAW_TEST=" https://raw.githubusercontent.com/DeepInThought/vscode-shell-snippets/master/README.md"
14- export GIT_COMMIT_MSG=
1516
1617__username=" $( whoami) "
1718__dir=" $( cd " $( dirname " ${HOME} " /" ${__username} " ) " && pwd) "
@@ -46,56 +47,58 @@ handle_exit_code() {
4647 fi
4748 printf -- ' \033[31m [ERROR] occurred. Cleaning up now...\033[0m\n'
4849 # ## Cleanup
49- printf -- ' \033[33m [CLEAN]: Cleaning exit properly.\n\033[31m [EXIT] with error code %s.\n' " ${ERROR_CODE} "
50+ printf -- ' \033[33m [CLEAN]: Cleaning exit properly.\n\033[31m [EXIT] with error code %s.\n' " ${ERROR_CODE} "
5051 exit " ${ERROR_CODE} "
5152}
5253trap " handle_exit_code" EXIT
5354
54- if [ -d " ${GIT_RAW_TEST} " ]; then
55+ # todo: Setup git credential fill
56+ # ## $(git credential fill \
57+ # ## protocol=https \
58+ # ## host="$GIT_REPOSITORY" \
59+ # ## username=deepinthought \
60+ # ## password="$GITHUB_PASSWORD" \
61+ # ## )
62+
63+ if [ ! " ${GIT_RAW_TEST} " ]; then
5564 echo " [Testing]: ${GIT_RAW_TEST} exists."
56- curl " ${GIT_RAW_TEST} " && echo || exit 2
57- printf -- ' \033[32m [SUCCESS]: %s \033[0m\n' ${GIT_RAW_TEST}
65+ curl " ${GIT_RAW_TEST} " || echo || exit 2
66+ printf -- ' \033[32m [SUCCESS]: %s \033[0m\n' ${GIT_RAW_TEST}
5867 sleep 1
59- else
68+ fi
69+ if [ ! -d " ${GIT_LOCAL_PATH} " ]; then
6070 echo " [GIT_RAW_TEST]: Not Setup! ${GIT_RAW_TEST} "
61- git clone " ${ROOT_PATH} / ${ GIT_REPOSITORY}" && echo || exit 2
71+ git clone " ${GIT_REPOSITORY} " || echo || exit 2
6272 printf -- ' \033[32m [SUCCESS]: %s \033[0m\n' " ${GIT_LOCAL_PATH} "
6373 sleep 1
6474fi
6575if [ $# -eq 1 ]; then
66- ${ GIT_COMMIT_MSG} = " $1 "
76+ GIT_COMMIT_MSG= $1
6777 ${GIT_REPOSITORY:- ' https://github.com/DeepInThought/vscode-shell-snippets.git' }
6878 echo " [Git Comment]: ${GIT-GIT_COMMIT_MSG} "
6979 echo " [Git Repository]: ${GIT_REPOSITORY} "
70- git commit -m ${GIT_COMMIT_MSG} || printf -- ' \033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
71- printf -- ' \033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
72- else
73- ${GIT_COMMIT_MSG:- " echo [Git Commit]: on $( date --rfc-3339=seconds) " }
74- git commit -m ${GIT_COMMIT_MSG} || printf -- ' \033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
75- printf -- ' \033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
80+ git commit -m " ${GIT_COMMIT_MSG} " || printf -- ' \033[31m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE:- 1} || exit 1
81+ printf -- ' \033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
7682fi
7783if [ $# -eq 2 ]; then
78- echo " [Git Comment]: ${GIT-COMMIT} "
79- echo " Commit on: $( date --rfc-3339=seconds) "
80- git commit -m ${GIT_COMMIT_MSG} || printf -- ' \033[32m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE} && exit 1
84+ GIT_COMMIT_MSG=" [Git Commit]: at $( date --rfc-3339=seconds) "
85+ echo " [Git Comment]: ${GIT_COMMIT_MSG} "
86+ echo " [Git Commit]: at $( date --rfc-3339=seconds) "
87+ git commit -m " ${GIT_COMMIT_MSG} " || printf -- ' \033[31m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE:- 2} || exit 1
8188 printf -- ' \033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
8289else
83- echo " Commit on: $( date --rfc-3339=seconds) " && echo " ${GIT_COMMIT_MSG} "
84- fi
85-
86- cd " ${GIT_LOCAL_PATH} " || exit 2
87- # Add changes to git.
88- git add .
89-
90- # Commit changes.
91- msg=" rebuilding site $( date) $theme_name "
92- if [ $# -eq 2 ]; then
93- msg=" $2 "
90+ GIT_COMMIT_MSG=" [Git Commit]: at $( date --rfc-3339=seconds) "
91+ echo " [Git Message]: ${GIT_COMMIT_MSG} "
92+ git commit -m " ${GIT_COMMIT_MSG} " || printf -- ' \033[31m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE:- 1} || exit 1
93+ printf -- ' \033[32m [Git Commit]: [FINISHED] without errors. \033[0m\n'
9494fi
95- git commit -m " $msg "
96-
97- # Push source and build repos.
98- git push origin master
9995
100- # Come Back up to the Project Root
101- cd ..
96+ if [ -d " ${GIT_LOCAL_PATH} " ]; then
97+ cd " ${GIT_LOCAL_PATH} " || echo " Current Dir: $PWD " || exit 2
98+ printf -- ' \033[32m [SUCCESS]: %s \033[0m\n' " ${GIT_LOCAL_PATH} "
99+ git add . || echo || exit 1
100+ printf -- ' \033[32m [SUCCESS]: git add . \033[0m\n'
101+ # ## Push and build the repository
102+ git push origin master || printf -- ' \033[31m [EXIT] with status code %s.\033[0m\n' ${ERROR_CODE:- 1} || exit 1
103+ printf -- ' \033[32m [SUCCESS]: git push origin master \033[0m\n'
104+ fi
0 commit comments