From f2094f5ef4e491f45965fc95313170205ca0d980 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 28 Sep 2022 00:17:17 -0400 Subject: [PATCH 1/2] Add owner and repo variables to commit message template --- src/persistence/persistence.ts | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/persistence/persistence.ts b/src/persistence/persistence.ts index a34e64fe..b1e8154c 100644 --- a/src/persistence/persistence.ts +++ b/src/persistence/persistence.ts @@ -38,15 +38,23 @@ export async function updateFile(sha: string, claFileContent, reactedCommitters: claFileContent?.signedContributors.push(...reactedCommitters.newSigned) let contentString = JSON.stringify(claFileContent, null, 2) let contentBinary = Buffer.from(contentString).toString("base64") + const owner = input.getRemoteOrgName() || context.repo.owner; + const repo = input.getRemoteRepoName() || context.repo.repo; + 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()) : - `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, - content: contentBinary, - branch: input.getBranch() - }) -} \ No newline at end of file + owner, + repo, + path: input.getPathToSignatures(), + sha, + message: input.getSignedCommitMessage() + ? input + .getSignedCommitMessage() + .replace("$contributorName", context.actor) + .replace("$pullRequestNo", context.issue.number.toString()) + .replace("$owner", owner) + .replace("$repo", repo) + : `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, + content: contentBinary, + branch: input.getBranch(), + }); +} From dd2772ea552f7e4979e28b0f7b50905fe4b48808 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 28 Sep 2022 00:51:12 -0400 Subject: [PATCH 2/2] Update persistence.ts --- src/persistence/persistence.ts | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/persistence/persistence.ts b/src/persistence/persistence.ts index b1e8154c..068cfe28 100644 --- a/src/persistence/persistence.ts +++ b/src/persistence/persistence.ts @@ -1,4 +1,3 @@ - import { octokit, octokitUsingPAT } from '../octokit' import { context } from '@actions/github' @@ -38,23 +37,20 @@ export async function updateFile(sha: string, claFileContent, reactedCommitters: claFileContent?.signedContributors.push(...reactedCommitters.newSigned) let contentString = JSON.stringify(claFileContent, null, 2) let contentBinary = Buffer.from(contentString).toString("base64") - const owner = input.getRemoteOrgName() || context.repo.owner; - const repo = input.getRemoteRepoName() || context.repo.repo; - await octokitInstance.repos.createOrUpdateFileContents({ - owner, - repo, - path: input.getPathToSignatures(), - sha, - message: input.getSignedCommitMessage() - ? input - .getSignedCommitMessage() - .replace("$contributorName", context.actor) - .replace("$pullRequestNo", context.issue.number.toString()) - .replace("$owner", owner) - .replace("$repo", repo) - : `@${context.actor} has signed the CLA from Pull Request #${pullRequestNo}`, - content: contentBinary, - branch: input.getBranch(), - }); + 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() + }) }