import { env } from "node:process" ; import { getOctokit } from "@actions/github" ; import { createAppAuth } from "@octokit/auth-app" ; import { request } from "@octokit/request" ; export const fetchInstallationToken = async ( { appId , installationId , owner , privateKey , repo , } ) : Promise < string > => { const app = createAppAuth ( { appId , privateKey , request : request . defaults ( { baseUrl : env . GITHUB_API_URL , } ) , } ) ; if ( installationId === undefined ) { const authApp = await app ( { type : "app" } ) ; const octokit = getOctokit ( authApp . token ) ; ( { data : { id : installationId } , } = await octokit . rest . apps . getRepoInstallation ( { owner , repo } ) ) ; } const installation = await app ( { installationId , type : "installation" } ) ; return installation . token ; } ;