From 3f9867224980ca2bacd547c61c1c52a1775c5e9d Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:18:23 -0400 Subject: [PATCH 01/13] t1 --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a2416fa..1b1ab12 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -# sandbox \ No newline at end of file +# sandbox + +123 \ No newline at end of file From 6735cba9d3f17d72a063418bc6494969c64dfba0 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:25:48 -0400 Subject: [PATCH 02/13] t2 --- .github/workflows/push_to_prod.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 73e225c..9a599f3 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -35,6 +35,7 @@ jobs: core.setFailed('No approvals from code owners.'); } else { console.log(`Found ${approvals.length} approval(s)`); + console.log(`Found ${approvals}`); } - name: Pull from main and push to production if: success() From 4b7711df6a1fd1625aeb816170f54bf75e19e2f6 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:28:18 -0400 Subject: [PATCH 03/13] t3 --- .github/workflows/push_to_prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 9a599f3..c0862c6 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -35,7 +35,7 @@ jobs: core.setFailed('No approvals from code owners.'); } else { console.log(`Found ${approvals.length} approval(s)`); - console.log(`Found ${approvals}`); + console.log(`Found ${approvals[0].user.login} as the first approver`); } - name: Pull from main and push to production if: success() From 7313fafdb82fa0c5ef3ec20225a7214e9384929b Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:38:54 -0400 Subject: [PATCH 04/13] tt2 --- .github/CODEOWNERS | 2 ++ .github/workflows/push_to_prod.yaml | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..800cedd --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# This is a CODEOWNERS file for the GitHub repository. +@cdc-as81 @gilsharon321 \ No newline at end of file diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index c0862c6..31d141a 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -28,14 +28,17 @@ jobs: repo: context.repo.repo, pull_number: prNumber }); + # make sure there is a code owner approval + # get code owners from the repository (.github/CODEOWNERS), read the file and load the code owners + console.log(context.repo.owner) + const codeOwners = "" + const reviewsFromCodeOwners = reviews.filter(r => + r.state === 'APPROVED' && codeOwners.includes(r.user.login) - const approvals = reviews.filter(r => r.state === 'APPROVED'); - - if (approvals.length === 0) { + if (reviewsFromCodeOwners.length === 0) { core.setFailed('No approvals from code owners.'); } else { console.log(`Found ${approvals.length} approval(s)`); - console.log(`Found ${approvals[0].user.login} as the first approver`); } - name: Pull from main and push to production if: success() From 0a6ed8c1eccbb40c0afe08d920d40622ee013cb7 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:41:06 -0400 Subject: [PATCH 05/13] dd --- .github/workflows/push_to_prod.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 31d141a..5b415cd 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -28,10 +28,8 @@ jobs: repo: context.repo.repo, pull_number: prNumber }); - # make sure there is a code owner approval - # get code owners from the repository (.github/CODEOWNERS), read the file and load the code owners - console.log(context.repo.owner) - const codeOwners = "" + console.log(context.repo.owner); + const codeOwners = ""; const reviewsFromCodeOwners = reviews.filter(r => r.state === 'APPROVED' && codeOwners.includes(r.user.login) From b5acd80ce78ed45862e66b313cfd32760702fe76 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:43:17 -0400 Subject: [PATCH 06/13] dd --- .github/workflows/push_to_prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 5b415cd..b573739 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -29,7 +29,7 @@ jobs: pull_number: prNumber }); console.log(context.repo.owner); - const codeOwners = ""; + const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners const reviewsFromCodeOwners = reviews.filter(r => r.state === 'APPROVED' && codeOwners.includes(r.user.login) From 014c20bf63f8249a7b16e41e944e5fe42b8e55c0 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:45:21 -0400 Subject: [PATCH 07/13] dd --- .github/workflows/push_to_prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index b573739..6cd269f 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -31,7 +31,7 @@ jobs: console.log(context.repo.owner); const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners const reviewsFromCodeOwners = reviews.filter(r => - r.state === 'APPROVED' && codeOwners.includes(r.user.login) + r.state === 'APPROVED' && codeOwners.includes(r.user.login)); if (reviewsFromCodeOwners.length === 0) { core.setFailed('No approvals from code owners.'); From b3ed8b134d9079a1e21eab8bf435bf5ed1300348 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:50:40 -0400 Subject: [PATCH 08/13] dd --- .github/workflows/push_to_prod.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 6cd269f..ae582ce 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -28,7 +28,6 @@ jobs: repo: context.repo.repo, pull_number: prNumber }); - console.log(context.repo.owner); const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners const reviewsFromCodeOwners = reviews.filter(r => r.state === 'APPROVED' && codeOwners.includes(r.user.login)); @@ -36,7 +35,7 @@ jobs: if (reviewsFromCodeOwners.length === 0) { core.setFailed('No approvals from code owners.'); } else { - console.log(`Found ${approvals.length} approval(s)`); + console.log(`Found ${reviewsFromCodeOwners.length} approvals from code owners`); } - name: Pull from main and push to production if: success() From a8fe3ab0619c9d4588181117f7bc1fe6690f3487 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Wed, 23 Jul 2025 13:58:06 -0400 Subject: [PATCH 09/13] dd --- .github/workflows/push_to_prod.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index ae582ce..7ab0e78 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -28,7 +28,8 @@ jobs: repo: context.repo.repo, pull_number: prNumber }); - const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners + //const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners + const codeOwners = ['cdc-as81']; // Replace with actual code owners const reviewsFromCodeOwners = reviews.filter(r => r.state === 'APPROVED' && codeOwners.includes(r.user.login)); From 57c0310981390e27e0dbf0e6023be2b1f0637b3d Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Fri, 25 Jul 2025 11:40:04 -0400 Subject: [PATCH 10/13] ss --- .github/workflows/push_to_prod.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 7ab0e78..9e0e867 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -29,7 +29,22 @@ jobs: pull_number: prNumber }); //const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners - const codeOwners = ['cdc-as81']; // Replace with actual code owners + const fs = require('fs'); + const path = require('path'); + const codeownersPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'CODEOWNERS'); + let codeOwners = []; + try { + const codeownersContent = fs.readFileSync(codeownersPath, 'utf8'); + codeOwners = codeownersContent + .split('\n') + .map(line => line.trim()) + .filter(line => line && !line.startsWith('#')) + .flatMap(line => line.split(/\s+/).slice(1)) // skip the pattern, get owners + .map(owner => owner.startsWith('@') ? owner.slice(1) : owner) + .filter((owner, idx, arr) => arr.indexOf(owner) === idx); // unique + } catch (err) { + core.setFailed(`Failed to read CODEOWNERS: ${err.message}`); + } const reviewsFromCodeOwners = reviews.filter(r => r.state === 'APPROVED' && codeOwners.includes(r.user.login)); From e03c2068655ebaff4352679df2208437417607cb Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Fri, 25 Jul 2025 11:50:32 -0400 Subject: [PATCH 11/13] ss --- .github/workflows/push_to_prod.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 9e0e867..8b9041a 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -31,7 +31,8 @@ jobs: //const codeOwners = ['cdc-as81', 'gilsharon321']; // Replace with actual code owners const fs = require('fs'); const path = require('path'); - const codeownersPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'CODEOWNERS'); + //const codeownersPath = path.join(process.env.GITHUB_WORKSPACE, '.github', 'CODEOWNERS'); + const codeownersPath = path.join('.github', 'CODEOWNERS'); let codeOwners = []; try { const codeownersContent = fs.readFileSync(codeownersPath, 'utf8'); From b9614356f5971047462b8103f039f2269fbe99d1 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Fri, 25 Jul 2025 12:03:31 -0400 Subject: [PATCH 12/13] ss --- .github/workflows/push_to_prod.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 8b9041a..5118a6b 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -16,6 +16,9 @@ jobs: with: ref: "main" fetch-depth: 0 + - name: List .github directory + run: ls -la + run: ls -la .github - name: Ensure PR was approved by Code Owner id: check_approval uses: actions/github-script@v7 From 4358446684cb8e3f54c8da0e6d97887a3ca00924 Mon Sep 17 00:00:00 2001 From: Gil Sharon Date: Fri, 25 Jul 2025 12:05:36 -0400 Subject: [PATCH 13/13] dd --- .github/workflows/push_to_prod.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_to_prod.yaml b/.github/workflows/push_to_prod.yaml index 5118a6b..65d0ac9 100644 --- a/.github/workflows/push_to_prod.yaml +++ b/.github/workflows/push_to_prod.yaml @@ -17,8 +17,9 @@ jobs: ref: "main" fetch-depth: 0 - name: List .github directory - run: ls -la - run: ls -la .github + run: | + ls -la + ls -la .github - name: Ensure PR was approved by Code Owner id: check_approval uses: actions/github-script@v7