Skip to content

Commit 38200a6

Browse files
committed
update GitHub API requests
1 parent 4459c2d commit 38200a6

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

scripts/fetch_and_build_deb

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if [ -z "${pkglatest}" ]; then
8888
exit $noinput
8989
fi
9090

91-
echo "header=\"Authorization: Bearer ${GITHUB_TOKEN}\"" > ~/.curlrc
91+
# echo "header=\"Authorization: Bearer ${GITHUB_TOKEN}\"" > ~/.curlrc not used currently
9292
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
9393

9494
export NAME
@@ -102,7 +102,9 @@ repopath="citusdata/${hubproj}"
102102

103103
echo "DEBUG: GITHUB_TOKEN length: ${#GITHUB_TOKEN}"
104104
curl -s -o /dev/null -w "DEBUG: commits endpoint HTTP=%{http_code}\n" \
105-
-H "Authorization: token ${GITHUB_TOKEN}" \
105+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
106+
-H "Accept: application/vnd.github+json" \
107+
-H "X-GitHub-Api-Version: 2022-11-28" \
106108
"https://api.github.com/repos/${repopath}/commits/${nightlyref}"
107109

108110
case "${1}" in
@@ -111,15 +113,23 @@ case "${1}" in
111113
releasetag="v${packageversion/'~'/-}"
112114
releasetag="${releasetag%.citus}"
113115

114-
gitsha=$(curl -s "https://api.github.com/repos/${repopath}/git/refs/tags/${releasetag}" | \
116+
gitsha=$(curl -sf \
117+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
118+
-H "Accept: application/vnd.github+json" \
119+
-H "X-GitHub-Api-Version: 2022-11-28" \
120+
"https://api.github.com/repos/${repopath}/git/refs/tags/${releasetag}" | \
115121
jq -r '.object.sha')
116122
if [ "${gitsha}" == 'null' ]; then
117123
echo "$0: could not determine commit for git tag ${releasetag}" >&2
118124
exit $failure
119125
fi
120126

121-
verified=$(curl -s "https://api.github.com/repos/${repopath}/releases/tags/${releasetag}" | \
122-
jq -r '.verify_tag // false')
127+
verified=$(curl -sf \
128+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
129+
-H "Accept: application/vnd.github+json" \
130+
-H "X-GitHub-Api-Version: 2022-11-28" \
131+
"https://api.github.com/repos/${repopath}/releases/tags/${releasetag}" | \
132+
jq -r '.verify_tag // false')
123133
if [ "${verified}" != 'true' ]; then
124134
echo "$0: could not verify release for tag ${releasetag}" >&2
125135
exit $failure
@@ -139,7 +149,10 @@ case "${1}" in
139149
setnextversion "${pkglatest}"
140150

141151
set +e
142-
gitsha=$(curl -sfH 'Accept:application/vnd.github+json' \
152+
gitsha=$(curl -sf \
153+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
154+
-H "Accept: application/vnd.github+json" \
155+
-H "X-GitHub-Api-Version: 2022-11-28" \
143156
"https://api.github.com/repos/${repopath}/commits/${ref}" | \
144157
jq -r '.sha')
145158
if [ "${?}" -ne 0 ]; then
@@ -161,8 +174,12 @@ esac
161174
tarballpath="${builddir}/${pkgname}_${packageversion}.orig.tar.gz"
162175
packagepath="${builddir}/${packageversion}"
163176

164-
curl -sL "https://api.github.com/repos/${repopath}/tarball/${gitsha}" \
165-
-o "${tarballpath}"
177+
curl -sfL \
178+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
179+
-H "Accept: application/vnd.github+json" \
180+
-H "X-GitHub-Api-Version: 2022-11-28" \
181+
"https://api.github.com/repos/${repopath}/tarball/${gitsha}" \
182+
-o "${tarballpath}"
166183

167184
mkdir -p "${packagepath}"
168185
tar xf "${tarballpath}" -C "${packagepath}" --strip-components 1

0 commit comments

Comments
 (0)