-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush
executable file
·62 lines (44 loc) · 1.56 KB
/
push
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
info() {
echo "============================================================================"
echo "[INFO] - $1"
echo "============================================================================"
}
error() {
echo "============================================================================"
echo "[ERROR] - $1"
echo "============================================================================"
}
warning() {
echo "============================================================================"
echo "[WARNING] - $1"
echo "============================================================================"
}
info "Getting path"
path=${1?Error: Path not provided}
info "Getting the commit message"
commitMessage=${2?Error: No commit message given};
info "Cding into provided path"
cd "$path"
info "Pulling from origin"
git pull
info "Staging all files"
git add .
info "Creating feature-branch"
git branch -M feature-branch
info "Committing with the given commit message"
git commit -m "$commitMessage"
info "Pushing to feature-branch"
git push origin feature-branch
info "Creating a PR with the title and body as commit message"
gh pr create --title "$commitMessage" --body "$commitMessage"
info "Waiting for 1 second"
sleep 1
info "Merging the PR with the branch as feature branch using the default merge"
gh pr merge feature-branch --merge
info "Checking out main branch"
git checkout main
info "Deleting feature branch"
git branch -D feature-branch || echo 'Feature branch already deleted'
info "Pulling from origin"
git pull