Skip to content

Commit 7c2b120

Browse files
committed
refactor: update scripts
1 parent 9af51bf commit 7c2b120

3 files changed

Lines changed: 33 additions & 18 deletions

File tree

scripts/fetch_and_build_deb

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

91-
if [ -z "${GH_TOKEN:-}" ]; then
92-
echo "$0: GH_TOKEN (GitHub App token) is required but not set" >&2
93-
exit 66
91+
# normalize token name (accept GH_TOKEN from CI) and fail fast — we only use installation tokens
92+
if [ -n "${GH_TOKEN:-}" ] && [ -z "${GITHUB_TOKEN:-}" ]; then
93+
export GITHUB_TOKEN="${GH_TOKEN}"
9494
fi
9595

96-
echo "header=\"Authorization: Bearer ${GH_TOKEN}\"" > ~/.curlrc
96+
if [ -z "${GITHUB_TOKEN:-}" ]; then
97+
echo "$0: error: GITHUB_TOKEN (installation token) is required" >&2
98+
exit $noinput
99+
fi
97100

98-
# ensuring GH_TOKEN usage for clones/fetches
99-
git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
101+
# use installation token for curl and git; keep token file permission-restricted
102+
printf 'header="Authorization: token %s"\n' "${GITHUB_TOKEN}" > ~/.curlrc
103+
chmod 600 ~/.curlrc
104+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
100105

101106
export NAME
102107
NAME=$(determine_name)

scripts/fetch_and_build_pgxn

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,20 @@ if [ -z "${pkglatest}" ]; then
5050
exit $noinput
5151
fi
5252

53-
if [ -z "${GH_TOKEN:-}" ]; then
54-
echo "$0: GH_TOKEN (GitHub App token) is required but not set" >&2
55-
exit 66
53+
# normalize token name (accept GH_TOKEN from CI) and fail fast — we only use installation tokens
54+
if [ -n "${GH_TOKEN:-}" ] && [ -z "${GITHUB_TOKEN:-}" ]; then
55+
export GITHUB_TOKEN="${GH_TOKEN}"
5656
fi
5757

58-
echo "header=\"Authorization: Bearer ${GH_TOKEN}\"" > ~/.curlrc
58+
if [ -z "${GITHUB_TOKEN:-}" ]; then
59+
echo "$0: error: GITHUB_TOKEN (installation token) is required" >&2
60+
exit $noinput
61+
fi
5962

60-
# ensuring GH_TOKEN usage for clones/fetches
61-
git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
63+
# use installation token for curl and git; keep token file permission-restricted
64+
printf 'header="Authorization: token %s"\n' "${GITHUB_TOKEN}" > ~/.curlrc
65+
chmod 600 ~/.curlrc
66+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
6267

6368
cp -R /buildfiles/META.json "${builddir}"
6469
repopath="citusdata/${hubproj}"

scripts/fetch_and_build_rpm

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,20 @@ if [ -z "${pkglatest}" ]; then
8181
exit $noinput
8282
fi
8383

84-
if [ -z "${GH_TOKEN:-}" ]; then
85-
echo "$0: GH_TOKEN (GitHub App token) is required but not set" >&2
86-
exit 66
84+
# normalize token name (accept GH_TOKEN from CI) and fail fast — we only use installation tokens
85+
if [ -n "${GH_TOKEN:-}" ] && [ -z "${GITHUB_TOKEN:-}" ]; then
86+
export GITHUB_TOKEN="${GH_TOKEN}"
8787
fi
8888

89-
echo "header=\"Authorization: Bearer ${GH_TOKEN}\"" > ~/.curlrc
89+
if [ -z "${GITHUB_TOKEN:-}" ]; then
90+
echo "$0: error: GITHUB_TOKEN (installation token) is required" >&2
91+
exit $noinput
92+
fi
9093

91-
# ensuring GH_TOKEN usage for clones/fetches
92-
git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
94+
# use installation token for curl and git; keep token file permission-restricted
95+
printf 'header="Authorization: token %s"\n' "${GITHUB_TOKEN}" > ~/.curlrc
96+
chmod 600 ~/.curlrc
97+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
9398

9499
name=$(determine_name)
95100
email=$(determine_email)

0 commit comments

Comments
 (0)