Skip to content

Commit 0202bec

Browse files
committed
Allow modifying dependencies if PR opened from the same repo (not from fork)
1 parent 7a7e37b commit 0202bec

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/guard-dependencies.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ jobs:
2424
const author = pr.user.login;
2525
const assoc = pr.author_association;
2626
27+
// Is PR branch in the same repo (not a fork)?
28+
const sameRepo =
29+
pr.head.repo != null && pr.head.repo.id === pr.base.repo.id;
30+
2731
const botAllowlist = new Set(['dependabot[bot]']);
2832
const orgAuthorAssociations = new Set(['MEMBER', 'OWNER']);
2933
3034
const allowed =
3135
botAllowlist.has(author) ||
36+
sameRepo ||
3237
(assoc != null && orgAuthorAssociations.has(assoc));
3338
3439
if (!allowed) {
@@ -48,5 +53,5 @@ jobs:
4853
4954
core.setFailed('Dependency changes are restricted to organization members.');
5055
} else {
51-
console.log(`Author ${author} (author_association=${assoc}) is allowed to make dependency changes.`);
56+
console.log(`Author ${author} (author_association=${assoc}, sameRepo=${sameRepo}) is allowed to make dependency changes.`);
5257
}

0 commit comments

Comments
 (0)