Skip to content

Commit c73fd99

Browse files
committed
detect GITHUB_TOKEN or GHAPP_TOKEN
Signed-off-by: Julio Jimenez <julio@clickhouse.com>
1 parent 3160711 commit c73fd99

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

entrypoint.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ download_sbom() {
4747

4848
# GitHub API URL for file content
4949
local api_url="https://api.github.com/repos/$repo/dependency-graph/sbom"
50+
51+
# Determine which token to use
52+
local auth_header=""
53+
if [[ -n "${GITHUB_TOKEN:-}" ]]; then
54+
auth_header="Authorization: Bearer $GITHUB_TOKEN"
55+
elif [[ -n "${GHAPP_TOKEN:-}" ]]; then
56+
auth_header="Authorization: Bearer $GHAPP_TOKEN"
57+
else
58+
log_error "No valid GitHub token found. Set GITHUB_TOKEN or GHAPP_TOKEN."
59+
exit 1
60+
fi
5061

51-
# Download file metadata to get download URL
52-
local response
62+
# Download SBOM file
5363
if curl -L \
5464
-H "Accept: application/vnd.github+json" \
55-
-H "Authorization: Bearer $GITHUB_TOKEN" \
65+
-H "$auth_header" \
5666
-H "X-GitHub-Api-Version: 2022-11-28" \
5767
"$api_url" \
5868
-o "$output_file"; then

0 commit comments

Comments
 (0)