-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactions_push.sh
57 lines (47 loc) · 1.37 KB
/
actions_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
49
50
51
52
53
54
55
56
57
#!/bin/bash
#
# Push functions
#
# Author: ttionya <[email protected]>
#################### Function ####################
########################################
# Push current ref to remote.
# Arguments:
# None
########################################
function push_current_ref() {
retry git push target "${GITHUB_REF}:${GITHUB_REF}" -f
}
########################################
# Push all branches and tags to remote.
# Arguments:
# None
# Outputs:
# branch information
########################################
function push_refs() {
# delete all local tags
git tag | xargs git tag -d
color blue "show all branches"
git branch --all
# fetch all branches and tags from origin
retry git fetch origin
if [[ $? -ne 0 ]]; then
color red "failed to fetch remote (origin) refs"
exit 1
fi
color blue "checkout local branch from remote branch"
git branch --remotes --list "origin/*" | sed 's|[ \t]||g' | grep -v "HEAD" | xargs -I {} git checkout --track {}
color blue "push all branches"
retry git push -u target -f --all
if [[ $? -ne 0 ]]; then
color red "failed to push branches to remote (target)"
exit 1
fi
color blue "push all tags"
retry git push -u target -f --tags
if [[ $? -ne 0 ]]; then
color red "failed to push tags to remote (target)"
exit 1
fi
}