File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # Usage example: /bin/sh ./git-push.sh wing328 swagger-petstore-perl "minor update"
3+
4+ git_user_id=$1
5+ git_repo_id=$2
6+ release_note=$3
7+
8+ if [ " $git_user_id " = " " ]; then
9+ git_user_id=" GIT_USER_ID"
10+ echo " [INFO] No command line input provided. Set \$ git_user_id to $git_user_id "
11+ fi
12+
13+ if [ " $git_repo_id " = " " ]; then
14+ git_repo_id=" GIT_REPO_ID"
15+ echo " [INFO] No command line input provided. Set \$ git_repo_id to $git_repo_id "
16+ fi
17+
18+ if [ " $release_note " = " " ]; then
19+ release_note=" Minor update"
20+ echo " [INFO] No command line input provided. Set \$ release_note to $release_note "
21+ fi
22+
23+ # Initialize the local directory as a Git repository
24+ git init
25+
26+ # Adds the files in the local repository and stages them for commit.
27+ git add .
28+
29+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
30+ git commit -m " $release_note "
31+
32+ # Sets the new remote
33+ git_remote=` git remote`
34+ if [ " $git_remote " = " " ]; then # git remote not defined
35+
36+ if [ " $GIT_TOKEN " = " " ]; then
37+ echo " [INFO] \$ GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
38+ git remote add origin https://github.com/${git_user_id} /${git_repo_id} .git
39+ else
40+ git remote add origin https://${git_user_id} :${GIT_TOKEN} @github.com/${git_user_id} /${git_repo_id} .git
41+ fi
42+
43+ fi
44+
45+ git pull origin master
46+
47+ # Pushes (Forces) the changes in the local repository up to the remote repository
48+ echo " Git pushing to https://github.com/${git_user_id} /${git_repo_id} .git"
49+ git push origin master 2>&1 | grep -v ' To https'
You can’t perform that action at this time.
0 commit comments