diff --git a/.github/actions/check-for-CLA/index.js b/.github/actions/check-for-CLA/index.js index 68684a92624a..bb39551976a1 100644 --- a/.github/actions/check-for-CLA/index.js +++ b/.github/actions/check-for-CLA/index.js @@ -142,6 +142,22 @@ const postCommentOnPullRequest = async (hasSignedCLA, errorFoundOnCLACheck) => { ); }; +const addLabelToPullRequest = async () => { + const octokit = new Octokit(); + + return octokit.request( + `POST /repos/${PULL_REQUST_INFO.owner}/${PULL_REQUST_INFO.repoName}/issues/${PULL_REQUST_INFO.id}/labels`, + { + labels: ["PR - Needs Signed CLA"], + headers: { + authorization: `bearer ${PULL_REQUST_INFO.gitHubToken}`, + accept: "application/vnd.github+json", + "X-GitHub-Api-Version": "2022-11-28", + }, + }, + ); +}; + const main = async () => { let hasSignedCLA; let errorFoundOnCLACheck; @@ -153,6 +169,9 @@ const main = async () => { } await postCommentOnPullRequest(hasSignedCLA, errorFoundOnCLACheck); + if (!hasSignedCLA) { + await addLabelToPullRequest(); + } }; main(); diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 60ffd52516e6..d4ed22242754 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -23,7 +23,7 @@ jobs: run: node index.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PULL_REQUEST_ID: ${{ github.event.number }} + PULL_REQUEST_ID: ${{ github.event.number }} GOOGLE_KEYS: ${{ secrets.GOOGLE_KEYS }} - INDIVIDUAL_CLA_SHEET_ID: ${{ secrets.INDIVIDUAL_CLA_SHEET_ID }} - CORPORATE_CLA_SHEET_ID: ${{ secrets.CORPORATE_CLA_SHEET_ID }} \ No newline at end of file + INDIVIDUAL_CLA_SHEET_ID: ${{ secrets.INDIVIDUAL_CLA_SHEET_ID }} + CORPORATE_CLA_SHEET_ID: ${{ secrets.CORPORATE_CLA_SHEET_ID }}