From c8e80ddc7a2b8b79cb8c7d0dfcbf9d6f058ff2d2 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 21:47:44 +0300 Subject: [PATCH 01/26] some changes --- main/entry1/nested.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/entry1/nested.ts b/main/entry1/nested.ts index 258a787..d405662 100644 --- a/main/entry1/nested.ts +++ b/main/entry1/nested.ts @@ -1 +1 @@ -export const nested = 'nested'; +export const nested = 'nested-new'; From 53d5f63491d8aeefdc635080dd2a3d148666a860 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 22:00:33 +0300 Subject: [PATCH 02/26] change action --- main/entry1/nested.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/entry1/nested.ts b/main/entry1/nested.ts index d405662..a0f3e14 100644 --- a/main/entry1/nested.ts +++ b/main/entry1/nested.ts @@ -1 +1 @@ -export const nested = 'nested-new'; +export const nested = 'nested-new-'; From ca3b3a78a4fce25061848a1fd3b79deab1b54369 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:32:02 +0300 Subject: [PATCH 03/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de22edd..8409bf6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: const { execSync } = require('child_process') const { commits } = context.payload.pull_request console.log(commits) - const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() + const rawFiles = execSync(`git diff-tree --no-commit-id --name-only -r HEAD`).toString() const files = rawFiles.split('\n').filter(Boolean) console.log(files) From 0f7e40ca1dc891fdcc10cb8b3d877fc7746bfef8 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:33:30 +0300 Subject: [PATCH 04/26] change action --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8409bf6..ab6f69b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: '2' - uses: pnpm/action-setup@v2 with: version: 8 From c3a4f9592e3d387f806344c117534d87715487cc Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:36:18 +0300 Subject: [PATCH 05/26] change action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab6f69b..fe940b4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,7 @@ jobs: const { commits } = context.payload.pull_request console.log(commits) const rawFiles = execSync(`git diff-tree --no-commit-id --name-only -r HEAD`).toString() + console.log('rawFiles', rawFiles) const files = rawFiles.split('\n').filter(Boolean) console.log(files) From c1c572b177ebf7beda49b062bd431065c36e95b5 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:37:22 +0300 Subject: [PATCH 06/26] change action --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe940b4..43f696c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,6 +21,8 @@ jobs: cache: 'pnpm' - name: Install modules run: pnpm install + - name: Check for automated commit + run: git diff-tree --no-commit-id --name-only -r HEAD - name: Check changed files uses: actions/github-script@v6 with: From bd865340a93c9845c8cf64ad48a08bfaf5eac3a8 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:40:37 +0300 Subject: [PATCH 07/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43f696c..95d92e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: - name: Install modules run: pnpm install - name: Check for automated commit - run: git diff-tree --no-commit-id --name-only -r HEAD + run: echo $(git diff-tree --no-commit-id --name-only -r HEAD) - name: Check changed files uses: actions/github-script@v6 with: From b1ae3d115c2be83758d9cb4f0312695b3c522f54 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:41:47 +0300 Subject: [PATCH 08/26] change action --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 95d92e5..00886d8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: '2' + - name: Check for automated commit 1 + run: echo $(git diff-tree --no-commit-id --name-only -r HEAD) - uses: pnpm/action-setup@v2 with: version: 8 From 78c9172ec4eb5d944606afe0c7084bde45f043dc Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:46:56 +0300 Subject: [PATCH 09/26] change action --- .github/workflows/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00886d8..a5f5cfb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,9 +11,8 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: '2' - - name: Check for automated commit 1 - run: echo $(git diff-tree --no-commit-id --name-only -r HEAD) + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 - uses: pnpm/action-setup@v2 with: version: 8 @@ -32,7 +31,7 @@ jobs: const { execSync } = require('child_process') const { commits } = context.payload.pull_request console.log(commits) - const rawFiles = execSync(`git diff-tree --no-commit-id --name-only -r HEAD`).toString() + const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() console.log('rawFiles', rawFiles) const files = rawFiles.split('\n').filter(Boolean) From 212a42ca636f861f0f4a1db330ad89f26e394562 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:51:33 +0300 Subject: [PATCH 10/26] change action --- .github/workflows/main.yml | 15 +++++++++++++++ main.ts => main.js | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) rename main.ts => main.js (57%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a5f5cfb..678163c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,3 +36,18 @@ jobs: const files = rawFiles.split('\n').filter(Boolean) console.log(files) + + const fs = require('fs'); + + const tsGraph = require('@andriyorehov/ts-graph'); + + const owners = fs.readFileSync('owners.json', 'utf8'); + const ownersObj = JSON.parse(owners); + + for (const owner of ownersObj) { + for (const entries of owner.owns) { + console.log(entries); + console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); + } + } + diff --git a/main.ts b/main.js similarity index 57% rename from main.ts rename to main.js index 9ef07ab..7494c8f 100644 --- a/main.ts +++ b/main.js @@ -1,6 +1,6 @@ -import fs from 'fs'; +const fs = require('fs'); -import { getTreeByFile } from '@andriyorehov/ts-graph'; +const tsGraph = require('@andriyorehov/ts-graph'); const owners = fs.readFileSync('owners.json', 'utf8'); const ownersObj = JSON.parse(owners); @@ -8,6 +8,6 @@ const ownersObj = JSON.parse(owners); for (const owner of ownersObj) { for (const entries of owner.owns) { console.log(entries); - console.log(Object.keys(getTreeByFile(entries).flatTree)); + console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); } } From cdf95aa21811035547ca3058cfda00456db428fa Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:57:45 +0300 Subject: [PATCH 11/26] change action --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 678163c..5c9b609 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,4 +50,6 @@ jobs: console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); } } + + execSync(`gh pr edit --add-reviewer andriyor`) From df367c50a90059dfc84f68f32dd6550f2cee2199 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Tue, 9 Apr 2024 23:59:04 +0300 Subject: [PATCH 12/26] change action --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c9b609..7af415f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,8 @@ jobs: run: echo $(git diff-tree --no-commit-id --name-only -r HEAD) - name: Check changed files uses: actions/github-script@v6 + env: + GH_TOKEN: ${{ github.token }} with: script: | const { execSync } = require('child_process') From 75ffa82b51e79f5bed8f28d67e607bfc79abd280 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:03:42 +0300 Subject: [PATCH 13/26] change action --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7af415f..2f0894d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: uses: actions/github-script@v6 env: GH_TOKEN: ${{ github.token }} + PR_NUMBER: ${{ github.event.number }} with: script: | const { execSync } = require('child_process') @@ -53,5 +54,5 @@ jobs: } } - execSync(`gh pr edit --add-reviewer andriyor`) + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer andriyor`) From 2b9d8dfb2545596c92483a8ea0e174713485385d Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:06:10 +0300 Subject: [PATCH 14/26] change action --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f0894d..ae20ade 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,10 @@ jobs: build: runs-on: ubuntu-latest steps: + - permissions: + contents: write + pull-requests: write + repository-projects: write - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} From 861b74076d7ff76b695829de7541e75d519874d4 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:12:04 +0300 Subject: [PATCH 15/26] change action --- .github/workflows/main.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ae20ade..b842e4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,14 +5,15 @@ on: branches: - main +permissions: + contents: write + pull-requests: write + repository-projects: write + jobs: build: runs-on: ubuntu-latest steps: - - permissions: - contents: write - pull-requests: write - repository-projects: write - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} From 383f199adf29f042c5dfc9bfbba38aebcdda1e51 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:21:55 +0300 Subject: [PATCH 16/26] change action --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b842e4a..ab56be3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,7 +54,6 @@ jobs: for (const owner of ownersObj) { for (const entries of owner.owns) { - console.log(entries); console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); } } From 4cf5dc33eda7c10b2f256054ecb6e55b6811adaf Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:25:07 +0300 Subject: [PATCH 17/26] change action --- .github/workflows/main.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab56be3..ba5c11e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,10 +5,8 @@ on: branches: - main -permissions: - contents: write - pull-requests: write - repository-projects: write +permissions: write-all + jobs: build: From af46f6995a0cc83a08fc8c101984967eeceac7fa Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:36:20 +0300 Subject: [PATCH 18/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba5c11e..7478fe2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,5 +56,5 @@ jobs: } } - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer andriyor`) + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer github-tooling/entry1`) From 94ab609c857daddf403a4db395a5867e2cf78e4b Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:38:04 +0300 Subject: [PATCH 19/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7478fe2..5551441 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,5 +56,5 @@ jobs: } } - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer github-tooling/entry1`) + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer noirkotyara`) From 6b3c0b61268e67fd3bfd6fed3ff39daa6b4bd51e Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 00:48:11 +0300 Subject: [PATCH 20/26] change action --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5551441..b34dd1b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,8 +5,6 @@ on: branches: - main -permissions: write-all - jobs: build: @@ -57,4 +55,3 @@ jobs: } execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer noirkotyara`) - From e2bd2bd67f9b2611c8852fdfb554909a5e21abd2 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:00:45 +0300 Subject: [PATCH 21/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b34dd1b..ab5eb34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: Check changed files uses: actions/github-script@v6 env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} PR_NUMBER: ${{ github.event.number }} with: script: | From d94786ae217ac2d3a50befa623e31e4617e452bc Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:03:03 +0300 Subject: [PATCH 22/26] change action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab5eb34..f5cf94a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,4 +54,4 @@ jobs: } } - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer noirkotyara`) + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer github-tooling/entry1`) From 4e55f2f28d64d9647f7dc57b43dcf38c26c444f5 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:12:04 +0300 Subject: [PATCH 23/26] change action --- .github/workflows/main.yml | 10 +++++----- owners.json | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5cf94a..a0a52f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,9 +37,9 @@ jobs: console.log(commits) const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() console.log('rawFiles', rawFiles) - const files = rawFiles.split('\n').filter(Boolean) + const changedFiles = rawFiles.split('\n').filter(Boolean) - console.log(files) + console.log(changedFiles) const fs = require('fs'); @@ -50,8 +50,8 @@ jobs: for (const owner of ownersObj) { for (const entries of owner.owns) { - console.log(Object.keys(tsGraph.getTreeByFile(entries).flatTree)); + const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); + if (changedFiles.some(file => paths.includes(file))) { + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) } } - - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer github-tooling/entry1`) diff --git a/owners.json b/owners.json index 7bdaa51..6125c68 100644 --- a/owners.json +++ b/owners.json @@ -1,10 +1,10 @@ [ { - "team": "entry1", + "team": "github-tooling/entry1", "owns": ["main/entry1/main.ts"] }, { - "team": "entry2", + "team": "github-tooling/entry2", "owns": ["main/entry2/main.ts"] } ] From 8896acc4e49a0dba883d32e4dca12a8e0aacd545 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:17:49 +0300 Subject: [PATCH 24/26] change action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0a52f5..856872d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,5 +53,6 @@ jobs: const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); if (changedFiles.some(file => paths.includes(file))) { execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) + } } } From f42d109d7e6e30e6e420ff5c10dfc7254c49568f Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:20:30 +0300 Subject: [PATCH 25/26] change action --- .github/scripts/main.js | 21 +++++++++++++++++++++ .github/workflows/main.yml | 25 ++----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 .github/scripts/main.js diff --git a/.github/scripts/main.js b/.github/scripts/main.js new file mode 100644 index 0000000..2305e4b --- /dev/null +++ b/.github/scripts/main.js @@ -0,0 +1,21 @@ +const fs = require('fs'); +const { execSync } = require('child_process') + +const tsGraph = require('@andriyorehov/ts-graph'); + +const { commits } = context.payload.pull_request + +const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() +const changedFiles = rawFiles.split('\n').filter(Boolean) + +const owners = fs.readFileSync('owners.json', 'utf8'); +const ownersObj = JSON.parse(owners); + +for (const owner of ownersObj) { + for (const entries of owner.owns) { + const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); + if (changedFiles.some(file => paths.includes(file))) { + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) + } + } +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 856872d..318cea4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,27 +32,6 @@ jobs: PR_NUMBER: ${{ github.event.number }} with: script: | - const { execSync } = require('child_process') - const { commits } = context.payload.pull_request - console.log(commits) - const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() - console.log('rawFiles', rawFiles) - const changedFiles = rawFiles.split('\n').filter(Boolean) + const script = require('.github/scripts/main.js') + script({github, context}) - console.log(changedFiles) - - const fs = require('fs'); - - const tsGraph = require('@andriyorehov/ts-graph'); - - const owners = fs.readFileSync('owners.json', 'utf8'); - const ownersObj = JSON.parse(owners); - - for (const owner of ownersObj) { - for (const entries of owner.owns) { - const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); - if (changedFiles.some(file => paths.includes(file))) { - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) - } - } - } From 312ed2b6964ffcb5fffa3c8bdb807c8579392af6 Mon Sep 17 00:00:00 2001 From: Andrii Oriekhov Date: Wed, 10 Apr 2024 01:21:55 +0300 Subject: [PATCH 26/26] change action --- .github/scripts/main.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/scripts/main.js b/.github/scripts/main.js index 2305e4b..ebbd55d 100644 --- a/.github/scripts/main.js +++ b/.github/scripts/main.js @@ -3,19 +3,22 @@ const { execSync } = require('child_process') const tsGraph = require('@andriyorehov/ts-graph'); -const { commits } = context.payload.pull_request -const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() -const changedFiles = rawFiles.split('\n').filter(Boolean) +module.exports = async ({ github, context }) => { + const { commits } = context.payload.pull_request -const owners = fs.readFileSync('owners.json', 'utf8'); -const ownersObj = JSON.parse(owners); + const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits}`).toString() + const changedFiles = rawFiles.split('\n').filter(Boolean) -for (const owner of ownersObj) { - for (const entries of owner.owns) { - const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); - if (changedFiles.some(file => paths.includes(file))) { - execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) + const owners = fs.readFileSync('owners.json', 'utf8'); + const ownersObj = JSON.parse(owners); + + for (const owner of ownersObj) { + for (const entries of owner.owns) { + const paths = Object.keys(tsGraph.getTreeByFile(entries).flatTree); + if (changedFiles.some(file => paths.includes(file))) { + execSync(`gh pr edit ${process.env.PR_NUMBER} --add-reviewer ${owner.team}`) + } } } -} +};