-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathclone-default-repo-pr-branch.sh
executable file
·68 lines (54 loc) · 2.2 KB
/
clone-default-repo-pr-branch.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
58
59
60
61
62
63
64
65
66
67
68
. ./.gh-api-examples.conf
if [ -z "$1" ]
then
repo=$repo
else
repo=$1
fi
if [ "${hostname}" = "api.github.com" ]; then
hostname=github.com
fi
# If you'd like to trace activity through the system
# set this user agent variable:
#
GIT_HTTP_USER_AGENT="the-power"
export GIT_HTTP_USER_AGENT
# In the babeld log you'll now get http_ua=the-power:
# Jun 10 07:40:31 ghe.test.com babeld[3395]: ts=2023-06-10T07:40:31.573371Z pid=1 tid=113 version=80b65cb proto=http id=366d5cb0f378a4f86f5bd64717c10b34 http_url="/acme/testrepo.git/info/refs?service=git-upload-pack" http_ua="the-power" i
# Set tracing debuggging settings if needed.
# youll need to uncomment the export below.
GIT_CURL_VERBOSE=1
GIT_TRACE=true
GIT_TRACE_PERFORMANCE=true
GIT_TRACE_SETUP=true
GIT_TRACE_PACKET=true
# uncomment the export line below to put settings into effect when running git commands:
# export GIT_SSH_COMMAND GIT_CURL_VERBOSE GIT_TRACE GIT_TRACE_PERFORMANCE GIT_TRACE_SETUP GIT_TRACE_PACKET GIT_CURL_VERBOSE
## The GIT_CURL_VERBOSE will give you the x-github-request-id
export GIT_CURL_VERBOSE
# See this url:
# https://github.blog/2012-09-21-easier-builds-and-deployments-using-git-over-https-and-oauth/
#
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installathon
# You can also use an installation access token to authenticate for
# HTTP-based Git access. You app must have the "Contents" repository
# permission. You can then use the installation access token as the HTTP
# password. Replace TOKEN with the installation access token: git clone
# https://x-access-token:[email protected]/owner/repo.git".
TOKEN_FRST3=${GITHUB_TOKEN:0:3}
echo ${TOKEN_FRST3}
cd src
rm -rf ${repo}
# You may need to use a flag like this in rare cases:
# git -c http.sslVerify=false
case ${TOKEN_FRST3} in
ghp)
git clone --branch ${branch_name} https://${GITHUB_TOKEN}:x-oauth-basic@${hostname}/${org}/${repo}.git
;;
ghu)
git clone --branch ${branch_name} https://${GITHUB_TOKEN}:x-oauth-basic@${hostname}/${org}/${repo}.git
;;
ghs)
git clone --branch ${branch_name} https://x-access-token:${GITHUB_TOKEN}@${hostname}/${org}/${repo}.git
;;
esac