Skip to content

Commit 20c0fa2

Browse files
dimsjustaugustus
andcommitted
Script to fork/create repositories needed by publishing-bot
Co-authored-by: Stephen Augustus (he/him) <[email protected]> Signed-off-by: Davanum Srinivas <[email protected]>
1 parent ea8d708 commit 20c0fa2

File tree

3 files changed

+127
-29
lines changed

3 files changed

+127
-29
lines changed

hack/create-repos.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")
22+
source "${SCRIPT_ROOT}/repos.sh"
23+
24+
if [ "$#" = 0 ] || [ "$#" -gt 2 ]; then
25+
echo "usage: $0 [source-github-user-name] dest-github-user-name"
26+
echo
27+
echo "This connects to [email protected]:<from>/<repo>. Set GITHUB_HOST to access git@<GITHUB_HOST>:<from>/<repo> instead."
28+
exit 1
29+
fi
30+
31+
FROM="kubernetes"
32+
TO="${1}"
33+
if [ "$#" -ge 2 ]; then
34+
FROM="${TO}"
35+
TO="${2}"
36+
fi
37+
GITHUB_HOST=${GITHUB_HOST:-github.com}
38+
39+
repo_count=${#repos[@]}
40+
41+
# safety check
42+
if [ "${TO}" = "kubernetes" ]; then
43+
echo "Cannot operate on kubernetes directly" 1>&2
44+
exit 1
45+
fi
46+
47+
destination_repos=( $(curl -ks https://api.github.com/orgs/${TO}/repos | jq ".[].name" | tr -d '"') )
48+
destination_repo_count=${#destination_repos[@]}
49+
50+
if ! command -v gh > /dev/null; then
51+
echo "Can't find 'gh' tool in PATH, please install from https://github.com/cli/cli"
52+
exit 1
53+
fi
54+
55+
# Checks if you are logged in. Will error/bail if you are not.
56+
gh auth status
57+
58+
echo "======================="
59+
echo " create repos if needed"
60+
echo "======================="
61+
for (( i=0; i<${repo_count}; i++ )); do
62+
found=0
63+
for (( j=0; j<${destination_repo_count}; j++ )); do
64+
if [[ "${repos[i]}" == ${destination_repos[j]} ]]; then
65+
found=1
66+
fi
67+
done
68+
if [[ $found -eq 1 ]]; then
69+
echo "repository found: ${repos[i]}"
70+
else
71+
echo "repository not found: ${repos[i]}"
72+
gh repo fork "kubernetes/${repos[i]}" --org "${TO}" --remote --clone=false
73+
fi
74+
done

hack/fetch-all-latest-and-push.sh

+3-29
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,9 @@ if [ "$#" -ge 2 ]; then
3232
TO="${2}"
3333
fi
3434
GITHUB_HOST=${GITHUB_HOST:-github.com}
35-
repos=(
36-
api
37-
apiextensions-apiserver
38-
apimachinery
39-
apiserver
40-
cli-runtime
41-
client-go
42-
cloud-provider
43-
cluster-bootstrap
44-
code-generator
45-
component-base
46-
component-helpers
47-
controller-manager
48-
cri-api
49-
csi-translation-lib
50-
kube-aggregator
51-
kube-controller-manager
52-
kube-proxy
53-
kube-scheduler
54-
kubectl
55-
kubelet
56-
legacy-cloud-providers
57-
metrics
58-
mount-utils
59-
pod-security-admission
60-
sample-apiserver
61-
sample-cli-plugin
62-
sample-controller
63-
)
35+
36+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")
37+
source "${SCRIPT_ROOT}/repos.sh"
6438

6539
repo_count=${#repos[@]}
6640

hack/repos.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2021 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
# shellcheck disable=SC2034
22+
repos=(
23+
api
24+
apiextensions-apiserver
25+
apimachinery
26+
apiserver
27+
cli-runtime
28+
client-go
29+
cloud-provider
30+
cluster-bootstrap
31+
code-generator
32+
component-base
33+
component-helpers
34+
controller-manager
35+
cri-api
36+
csi-translation-lib
37+
kube-aggregator
38+
kube-controller-manager
39+
kube-proxy
40+
kube-scheduler
41+
kubectl
42+
kubelet
43+
legacy-cloud-providers
44+
metrics
45+
mount-utils
46+
pod-security-admission
47+
sample-apiserver
48+
sample-cli-plugin
49+
sample-controller
50+
)

0 commit comments

Comments
 (0)