1
0
Fork 0

Comments Resolved

pull/867/head
Sourav Chanduka 2021-07-12 08:37:14 +05:30
parent bdacfc4c65
commit 1322acbcca
3 changed files with 8 additions and 16 deletions

View File

@ -14,18 +14,8 @@ export function getIDTokenUrl(): string {
return runtimeUrl return runtimeUrl
} }
export function getWorkFlowRunId(): string {
const workFlowRunId = process.env['GITHUB_RUN_ID']
if (!workFlowRunId) {
throw new Error('Unable to get GITHUB_RUN_ID env variable')
}
return workFlowRunId
}
export function getIDTokenFromEnv(): string { export function getIDTokenFromEnv(): string {
const tokenId = process.env['OIDC_TOKEN_ID'] //Need to check the exact env var name const tokenId = process.env['OIDC_TOKEN_ID'] //Need to check the exact env var name
if(!tokenId) {
throw new Error('Unable to get OIDC_TOKEN_ID env variable')
}
return tokenId return tokenId
} }

View File

@ -23,8 +23,7 @@ import {
]) ])
} }
export function getApiVersion(): string { export function getApiVersion(): string {
return '1.0' return '2.0'
} }

View File

@ -41,8 +41,11 @@ export async function getIDToken(audience: string): Promise<string> {
} }
core.debug(`Httpclient created ${httpclient} `) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true core.debug(`Httpclient created ${httpclient} `) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
var additionalHeaders = {[httpclient.Headers.ContentType]: httpclient.MediaTypes.ApplicationJson}
const response = await httpclient.post(id_tokne_url, audience) var data : String = new String('id_token_aud:')
data = data.concat(audience)
const response = await httpclient.post(id_tokne_url, data, additionalHeaders)
if (!isSuccessStatusCode(response.message.statusCode)){ if (!isSuccessStatusCode(response.message.statusCode)){
@ -53,7 +56,7 @@ export async function getIDToken(audience: string): Promise<string> {
const body: string = await response.readBody() const body: string = await response.readBody()
const val = JSON.parse(body) const val = JSON.parse(body)
id_token = val['id_token'] id_token = val['value']
if (id_token == undefined) { if (id_token == undefined) {
throw new Error(`Not able to fetch the ID token`) throw new Error(`Not able to fetch the ID token`)