Skip to content

Commit ec94bea

Browse files
author
Alexander Rogalskiy
committed
Updates on files
1 parent 0264c40 commit ec94bea

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

scripts/git-push.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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'

0 commit comments

Comments
 (0)