From 44dffd1365bc81893b99c262bb864cfddfba7f5e Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 09:37:16 +0100 Subject: [PATCH 01/10] Update cla.yml --- .github/workflows/cla.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 9466025d..293001e8 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -12,7 +12,7 @@ jobs: - name: "CLA Assistant" if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' # Beta Release - uses: cla-assistant/github-action@v2.1.3-beta + uses: cla-assistant/github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # the below token should have repo scope and must be manually added by you in the repository's secret From 44f394b13b877b93deeee3ed82f34221b1ec8677 Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 09:39:11 +0100 Subject: [PATCH 02/10] Update cla.yml --- .github/workflows/cla.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 293001e8..4c9347f4 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -16,7 +16,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # the below token should have repo scope and must be manually added by you in the repository's secret - PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} + # PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: path-to-signatures: 'signatures/version1/cla.json' path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document From 39744ee9c5b79debcef06ef40db499b5dba81984 Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 09:40:49 +0100 Subject: [PATCH 03/10] Update cla.yml --- .github/workflows/cla.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 4c9347f4..293001e8 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -16,7 +16,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # the below token should have repo scope and must be manually added by you in the repository's secret - # PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} + PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: path-to-signatures: 'signatures/version1/cla.json' path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document From e35c031ec0b0a44ec3ea3bcfe1b02413fd55cea2 Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 09:44:24 +0100 Subject: [PATCH 04/10] Update cla.yml --- .github/workflows/cla.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 293001e8..4c9347f4 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -16,7 +16,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # the below token should have repo scope and must be manually added by you in the repository's secret - PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} + # PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: path-to-signatures: 'signatures/version1/cla.json' path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document From c36a1ecbaad278f952ff4ab756b1a09dc31f6cb2 Mon Sep 17 00:00:00 2001 From: ibakshay Date: Thu, 9 Feb 2023 10:05:43 +0100 Subject: [PATCH 05/10] fixes a bug --- dist/index.js | 26 ++++++++++++++++---------- src/octokit.ts | 9 +++------ src/persistence/persistence.ts | 23 +++++++++++++++++++---- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/dist/index.js b/dist/index.js index 92bc9c12..0ca7390c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -181,18 +181,16 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isPersonalAccessTokenPresent = exports.getPATOctokit = exports.octokit = void 0; +exports.isPersonalAccessTokenPresent = exports.getPATOctokit = exports.getDefaultOctokitClient = exports.octokit = void 0; const github_1 = __webpack_require__(469); const core = __importStar(__webpack_require__(470)); const githubActionsDefaultToken = process.env.GITHUB_TOKEN; const personalAccessToken = process.env.PERSONAL_ACCESS_TOKEN; exports.octokit = (0, github_1.getOctokit)(githubActionsDefaultToken); -/*export async function getOctokitClient() { - if (isPersonalAccessTokenPresent()) { - return getPATOctokit() - } - return octokit -}*/ +function getDefaultOctokitClient() { + return (0, github_1.getOctokit)(githubActionsDefaultToken); +} +exports.getDefaultOctokitClient = getDefaultOctokitClient; function getPATOctokit() { if (!isPersonalAccessTokenPresent()) { core.setFailed(`Please add a personal access token as an environment variable for writing signatures in a remote repository/organization as mentioned in the README.md file`); @@ -1876,7 +1874,7 @@ const octokit_1 = __webpack_require__(28); const input = __importStar(__webpack_require__(555)); function getFileContent() { return __awaiter(this, void 0, void 0, function* () { - const octokitInstance = (0, octokit_1.getPATOctokit)(); + const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)(); const result = yield octokitInstance.repos.getContent({ owner: input.getRemoteOrgName() || github_1.context.repo.owner, repo: input.getRemoteRepoName() || github_1.context.repo.repo, @@ -1889,7 +1887,7 @@ function getFileContent() { exports.getFileContent = getFileContent; function createFile(contentBinary) { return __awaiter(this, void 0, void 0, function* () { - const octokitInstance = (0, octokit_1.getPATOctokit)(); + const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)(); return octokitInstance.repos.createOrUpdateFileContents({ owner: input.getRemoteOrgName() || github_1.context.repo.owner, repo: input.getRemoteRepoName() || github_1.context.repo.repo, @@ -1904,7 +1902,7 @@ function createFile(contentBinary) { exports.createFile = createFile; function updateFile(sha, claFileContent, reactedCommitters) { return __awaiter(this, void 0, void 0, function* () { - const octokitInstance = (0, octokit_1.getPATOctokit)(); + const octokitInstance = isRemoteRepoOrOrgConfigured() ? (0, octokit_1.getPATOctokit)() : (0, octokit_1.getDefaultOctokitClient)(); const pullRequestNo = github_1.context.issue.number; claFileContent === null || claFileContent === void 0 ? void 0 : claFileContent.signedContributors.push(...reactedCommitters.newSigned); let contentString = JSON.stringify(claFileContent, null, 2); @@ -1925,6 +1923,14 @@ function updateFile(sha, claFileContent, reactedCommitters) { }); } exports.updateFile = updateFile; +function isRemoteRepoOrOrgConfigured() { + let isRemoteRepoOrOrgConfigured = false; + if ((input === null || input === void 0 ? void 0 : input.getRemoteRepoName()) || input.getRemoteOrgName()) { + isRemoteRepoOrOrgConfigured = true; + return isRemoteRepoOrOrgConfigured; + } + return isRemoteRepoOrOrgConfigured; +} /***/ }), diff --git a/src/octokit.ts b/src/octokit.ts index 2b9a17ba..bb94dfd6 100644 --- a/src/octokit.ts +++ b/src/octokit.ts @@ -7,12 +7,9 @@ const personalAccessToken = process.env.PERSONAL_ACCESS_TOKEN as string export const octokit = getOctokit(githubActionsDefaultToken as string) -/*export async function getOctokitClient() { - if (isPersonalAccessTokenPresent()) { - return getPATOctokit() - } - return octokit -}*/ +export function getDefaultOctokitClient() { + return getOctokit(githubActionsDefaultToken as string) +} export function getPATOctokit() { if (!isPersonalAccessTokenPresent()) { core.setFailed( diff --git a/src/persistence/persistence.ts b/src/persistence/persistence.ts index 9e134ee0..6f93a77c 100644 --- a/src/persistence/persistence.ts +++ b/src/persistence/persistence.ts @@ -2,12 +2,14 @@ import { context } from '@actions/github' import { ReactedCommitterMap } from '../interfaces' import { GitHub } from '@actions/github/lib/utils' -import { getPATOctokit } from '../octokit' +import { getDefaultOctokitClient, getPATOctokit } from '../octokit' import * as input from '../shared/getInputs' export async function getFileContent(): Promise { - const octokitInstance: InstanceType = getPATOctokit() + const octokitInstance: InstanceType = + isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient() + const result = await octokitInstance.repos.getContent({ owner: input.getRemoteOrgName() || context.repo.owner, repo: input.getRemoteRepoName() || context.repo.repo, @@ -18,7 +20,9 @@ export async function getFileContent(): Promise { } export async function createFile(contentBinary): Promise { - const octokitInstance: InstanceType = getPATOctokit() + const octokitInstance: InstanceType = + isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient() + return octokitInstance.repos.createOrUpdateFileContents({ owner: input.getRemoteOrgName() || context.repo.owner, repo: input.getRemoteRepoName() || context.repo.repo, @@ -36,7 +40,9 @@ export async function updateFile( claFileContent, reactedCommitters: ReactedCommitterMap ): Promise { - const octokitInstance: InstanceType = getPATOctokit() + const octokitInstance: InstanceType = + isRemoteRepoOrOrgConfigured() ? getPATOctokit() : getDefaultOctokitClient() + const pullRequestNo = context.issue.number claFileContent?.signedContributors.push(...reactedCommitters.newSigned) let contentString = JSON.stringify(claFileContent, null, 2) @@ -55,3 +61,12 @@ export async function updateFile( branch: input.getBranch() }) } + +function isRemoteRepoOrOrgConfigured(): boolean { + let isRemoteRepoOrOrgConfigured = false + if (input?.getRemoteRepoName() || input.getRemoteOrgName()) { + isRemoteRepoOrOrgConfigured = true + return isRemoteRepoOrOrgConfigured + } + return isRemoteRepoOrOrgConfigured +} From d3708e7f6ba73189b106c33d359c1a6bff34f836 Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 10:07:46 +0100 Subject: [PATCH 06/10] Update cla.yml --- .github/workflows/cla.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 4c9347f4..495cf58a 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -21,7 +21,7 @@ jobs: path-to-signatures: 'signatures/version1/cla.json' path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document # branch should not be protected - branch: 'main' + branch: 'master' allowlist: user1,bot* #below are the optional inputs - If the optional inputs are not given, then default values will be taken From 340dffba2527aed71bb30921f6afc04f2a7b62df Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 09:08:26 +0000 Subject: [PATCH 07/10] Creating file for storing CLA Signatures --- signatures/version1/cla.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 signatures/version1/cla.json diff --git a/signatures/version1/cla.json b/signatures/version1/cla.json new file mode 100644 index 00000000..18d5487f --- /dev/null +++ b/signatures/version1/cla.json @@ -0,0 +1,3 @@ +{ + "signedContributors": [] +} \ No newline at end of file From dec35f96d7dda569931dcd3f5acb26f4d323437d Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 10:08:54 +0100 Subject: [PATCH 08/10] Delete SAPCLA.md --- SAPCLA.md | 66 ------------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 SAPCLA.md diff --git a/SAPCLA.md b/SAPCLA.md deleted file mode 100644 index 3f0d2eb3..00000000 --- a/SAPCLA.md +++ /dev/null @@ -1,66 +0,0 @@ -### SAP Individual Contributor License Agreement - -Thank you for your interest in contributing to open source software projects (“Projects”) made available by SAP SE or its affiliates (“SAP”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to SAP in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact opensource@sap.com. - - -You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions. - - -**Copyright License.** You hereby grant, and agree to grant, to SAP a non-exclusive, perpetual, irrevocable, worldwide, fully-paid, royalty-free, transferable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute your Contributions and such derivative works, with the right to sublicense the foregoing rights through multiple tiers of sublicensees. - - -**Patent License.** You hereby grant, and agree to grant, to SAP a non-exclusive, perpetual, irrevocable, -worldwide, fully-paid, royalty-free, transferable patent license to make, have made, use, offer to sell, sell, -import, and otherwise transfer your Contributions, where such license applies only to those patent claims -licensable by you that are necessarily infringed by your Contributions alone or by combination of your -Contributions with the Project to which such Contributions were submitted, with the right to sublicense the -foregoing rights through multiple tiers of sublicensees. - - -**Moral Rights.** To the fullest extent permitted under applicable law, you hereby waive, and agree not to -assert, all of your “moral rights” in or relating to your Contributions for the benefit of SAP, its assigns, and -their respective direct and indirect sublicensees. - - -**Third Party Content/Rights.** If your Contribution includes or is based on any source code, object code, bug -fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or -other works of authorship that were not authored by you (“Third Party Content”) or if you are aware of any -third party intellectual property or proprietary rights associated with your Contribution (“Third Party Rights”), -then you agree to include with the submission of your Contribution full details respecting such Third Party -Content and Third Party Rights, including, without limitation, identification of which aspects of your -Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the -Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable -third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater -certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights -do not apply to any portion of a Project that is incorporated into your Contribution to that same Project. - - -**Representations.** You represent that, other than the Third Party Content and Third Party Rights identified by -you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled -to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were -created in the course of your employment with your past or present employer(s), you represent that such -employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer -(s) has waived all of their right, title or interest in or to your Contributions. - - -**Disclaimer.** To the fullest extent permitted under applicable law, your Contributions are provided on an "asis" -basis, without any warranties or conditions, express or implied, including, without limitation, any implied -warranties or conditions of non-infringement, merchantability or fitness for a particular purpose. You are not -required to provide support for your Contributions, except to the extent you desire to provide support. - - -**No Obligation.** You acknowledge that SAP is under no obligation to use or incorporate your Contributions -into any of the Projects. The decision to use or incorporate your Contributions into any of the Projects will be -made at the sole discretion of SAP or its authorized delegates .. - - -**Disputes.** This Agreement shall be governed by and construed in accordance with the laws of the State of -New York, United States of America, without giving effect to its principles or rules regarding conflicts of laws, -other than such principles directing application of New York law. The parties hereby submit to venue in, and -jurisdiction of the courts located in New York, New York for purposes relating to this Agreement. In the event -that any of the provisions of this Agreement shall be held by a court or other tribunal of competent jurisdiction -to be unenforceable, the remaining portions hereof shall remain in full force and effect. - - -**Assignment.** You agree that SAP may assign this Agreement, and all of its rights, obligations and licenses -hereunder. From 689f9c409b19d371b5c208f189a01acba4c44c2b Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 10:09:04 +0100 Subject: [PATCH 09/10] Delete cla.json --- signatures/version1/cla.json | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 signatures/version1/cla.json diff --git a/signatures/version1/cla.json b/signatures/version1/cla.json deleted file mode 100644 index 18d5487f..00000000 --- a/signatures/version1/cla.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "signedContributors": [] -} \ No newline at end of file From 724af84382d9b2a60b20f5905acfa69b5d5f86ee Mon Sep 17 00:00:00 2001 From: Akshay Iyyadurai Balasundaram Date: Thu, 9 Feb 2023 10:09:32 +0100 Subject: [PATCH 10/10] Delete cla.yml --- .github/workflows/cla.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/cla.yml diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml deleted file mode 100644 index 495cf58a..00000000 --- a/.github/workflows/cla.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "CLA Assistant" -on: - issue_comment: - types: [created] - pull_request_target: - types: [opened,closed,synchronize] - -jobs: - CLAssistant: - runs-on: ubuntu-latest - steps: - - name: "CLA Assistant" - if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - # Beta Release - uses: cla-assistant/github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # the below token should have repo scope and must be manually added by you in the repository's secret - # PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }} - with: - path-to-signatures: 'signatures/version1/cla.json' - path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document - # branch should not be protected - branch: 'master' - allowlist: user1,bot* - - #below are the optional inputs - If the optional inputs are not given, then default values will be taken - #remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository) - #remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository) - #create-file-commit-message: 'For example: Creating file for storing CLA Signatures' - #signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo' - #custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign' - #custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA' - #custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.' - #lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true) - #use-dco-flag: true - If you are using DCO instead of CLA