Skip to content

Commit 4ed14ce

Browse files
committed
add http log for gh
1 parent 11ba713 commit 4ed14ce

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/utils/oidc.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,32 @@ async function oidc ({ packageName, registry, opts, config }) {
7777
log.silly('oidc', `Using audience: ${audience}`)
7878
const url = new URL(process.env.ACTIONS_ID_TOKEN_REQUEST_URL)
7979
url.searchParams.append('audience', audience)
80+
const startTime = Date.now()
8081
const response = await fetch(url.href, {
8182
retry: opts.retry,
8283
headers: {
8384
Accept: 'application/json',
8485
Authorization: `Bearer ${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}`,
8586
},
8687
})
87-
log.silly('oidc', `Github Actions fetch for id_token response status: ${response.status}`)
88+
89+
const elapsedTime = Date.now() - startTime
90+
91+
log.http(
92+
'fetch',
93+
`GET ${url.href} ${response.status} ${elapsedTime}ms`
94+
)
95+
96+
const json = await response.json()
97+
8898
if (!response.ok) {
8999
throw new Error(`Failed to fetch id_token from GitHub: received an invalid response`)
90100
}
91-
const json = await response.json()
101+
92102
if (!json.value) {
93103
throw new Error(`Failed to fetch id_token from GitHub: missing value`)
94104
}
105+
95106
log.silly('oidc', 'GITHUB_ACTIONS valid fetch response for id_token')
96107
idToken = json.value
97108
} else {

0 commit comments

Comments
 (0)