Skip to content

Commit

Permalink
change action
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyor committed Apr 9, 2024
1 parent f42d109 commit 312ed2b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions .github/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
}
}
}
};

0 comments on commit 312ed2b

Please sign in to comment.