diff --git a/dist/index.js b/dist/index.js index 0ca7390c..70b11dc6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1904,6 +1904,7 @@ function updateFile(sha, claFileContent, reactedCommitters) { return __awaiter(this, void 0, void 0, function* () { const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)(); const pullRequestNo = github_1.context.issue.number; + console.log(JSON.stringify(github_1.context.issue, null, 3)); claFileContent === null || claFileContent === void 0 ? void 0 : claFileContent.signedContributors.push(...reactedCommitters.newSigned); let contentString = JSON.stringify(claFileContent, null, 2); let contentBinary = Buffer.from(contentString).toString('base64'); @@ -1916,6 +1917,9 @@ function updateFile(sha, claFileContent, reactedCommitters) { ? input .getSignedCommitMessage() .replace('$contributorName', github_1.context.actor) + .replace('$pullRequestNo', github_1.context.issue.number.toString()) + .replace('$owner', github_1.context.issue.owner) + .replace('$repo', github_1.context.issue.repo) : `@${github_1.context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, content: contentBinary, branch: input.getBranch() diff --git a/src/persistence/persistence.ts b/src/persistence/persistence.ts index ecbee079..cbb63bea 100644 --- a/src/persistence/persistence.ts +++ b/src/persistence/persistence.ts @@ -35,30 +35,35 @@ export async function createFile(contentBinary): Promise { }) } -export async function updateFile(sha: string, claFileContent, reactedCommitters: ReactedCommitterMap): Promise { - - const octokitInstance: InstanceType = +export async function updateFile( + sha: string, + claFileContent, + reactedCommitters: ReactedCommitterMap +): Promise { + const octokitInstance: InstanceType = isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient() - const pullRequestNo = context.issue.number - claFileContent?.signedContributors.push(...reactedCommitters.newSigned) - let contentString = JSON.stringify(claFileContent, null, 2) - let contentBinary = Buffer.from(contentString).toString("base64") - await octokitInstance.repos.createOrUpdateFileContents({ - owner: input.getRemoteOrgName() || context.repo.owner, - repo: input.getRemoteRepoName() || context.repo.repo, - path: input.getPathToSignatures(), - sha, - message: input.getSignedCommitMessage() - ? input - .getSignedCommitMessage() - .replace("$contributorName", context.actor) - .replace("$pullRequestNo", context.issue.number.toString()) - .replace("$owner", context.issue.owner) - .replace("$repo", context.issue.repo) - : `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, - content: contentBinary, - branch: input.getBranch() - }) + + const pullRequestNo = context.issue.number + console.log(JSON.stringify(context.issue, null, 3)) + claFileContent?.signedContributors.push(...reactedCommitters.newSigned) + let contentString = JSON.stringify(claFileContent, null, 2) + let contentBinary = Buffer.from(contentString).toString('base64') + await octokitInstance.repos.createOrUpdateFileContents({ + owner: input.getRemoteOrgName() || context.repo.owner, + repo: input.getRemoteRepoName() || context.repo.repo, + path: input.getPathToSignatures(), + sha, + message: input.getSignedCommitMessage() + ? input + .getSignedCommitMessage() + .replace('$contributorName', context.actor) + .replace('$pullRequestNo', context.issue.number.toString()) + .replace('$owner', context.issue.owner) + .replace('$repo', context.issue.repo) + : `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, + content: contentBinary, + branch: input.getBranch() + }) } function isRemoteRepoOrOrgConfigured(): boolean {