-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync_code.sh
More file actions
executable file
·67 lines (60 loc) · 2.06 KB
/
Copy pathsync_code.sh
File metadata and controls
executable file
·67 lines (60 loc) · 2.06 KB
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
63
64
65
66
#!/bin/bash
# see: <https://github.com/TobKed/github-forks-sync-action.git>
# see: <https://github.com/sudo-bot/action-fork-sync.git>
#set -e
ACCESS_TOKEN=$1
ACTOR=$2
[[ -z "$ACTOR" ]] && ACTOR=${GITHUB_ACTOR}
if [ -z "$ACCESS_TOKEN" -o -z "$ACTOR" ]; then
echo "ACCESS_TOKEN or ACTOR is null"
echo "Usage: $0 ACCESS_TOKEN [ACTOR]"
exit 1
fi
echo "ACCESS_TOKEN: $ACCESS_TOKEN"
echo "ACTOR: $ACTOR"
# 定义需要同步的仓库
# 名字一样,可以只写上游仓库即可
# 名字不一样,需要在后面加上自己取的名称如,并用括号
repos=(
https://github.com/coolsnowwolf/lede.git
https://github.com/coolsnowwolf/packages.git
https://github.com/coolsnowwolf/luci.git
https://github.com/coolsnowwolf/routing.git
https://github.com/fw876/helloworld.git
https://github.com/jerrykuku/luci-theme-argon.git
https://github.com/jerrykuku/luci-app-argon-config.git
https://github.com/kiddin9/luci-app-dnsfilter.git
https://github.com/destan19/OpenAppFilter.git
https://github.com/openwrt/telephony.git
#"https://github.com/openwrt/packages.git openwrt-packages"
#"https://github.com/openwrt/routing openwrt-routing"
#"https://github.com/openwrt/luci openwrt-luci"
)
sync() {
upstream="$1"
name="$2"
[[ -z "$name" ]] && name=`echo "${1##*/}" | sed 's/\.git//'`
#target="https://${GITHUB_ACTOR}:${ACCESS_TOKEN}@github.com/${GITHUB_ACTOR}/${name}.git"
target="https://${ACTOR}:${ACCESS_TOKEN}@github.com/${ACTOR}/${name}.git"
echo "upstream: [${upstream}] to target: [${target}]"
#OPTS="--dry-run"
#rm -fr $name
#[[ -d $name ]] || git clone --bare --no-single-branch "${upstream}" "${name}"
rm -fr $name
git clone --bare --no-single-branch "${upstream}" "${name}"
cd $name
# --mirror 会删除自己创建的内容,如分支和 tag 等
# 推送了 ref/*,且强制,并删除原有,相当加了 --force and --prune
# 仓库弄乱了可以用这个命令恢复
#git push --mirror "${target}"
# 只推送 ref/heads/*
git push --all "${target}"
# 只推送 ref/tags/*
git push --tags "${target}"
}
i=1
for r in "${repos[@]}"; do
echo "$i: $r"
((i=i+1))
sync $r
done