Skip to content

Commit

Permalink
Repo Gardening: check if PR owner is a member of the org to determine…
Browse files Browse the repository at this point in the history
… if they're an OSS Citizen (#36860)

* check if user is a member of the org

* Changelog

* fix changelog typo

* Version fixup

* Only check for membership on fork PRs
  • Loading branch information
vcanales authored Apr 15, 2024
1 parent e8db235 commit be64b86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Repo Gardening: Check if PR owner is a member of the organization to determine if they're an OSS Citizen
2 changes: 1 addition & 1 deletion projects/github-actions/repo-gardening/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "repo-gardening",
"version": "5.0.1-alpha",
"version": "5.1.0-alpha",
"description": "Manage Pull Requests and issues in your Open Source project (automate labelling, milestones, feedback to PR authors, ...)",
"author": "Automattic",
"license": "GPL-2.0-or-later",
Expand Down
11 changes: 11 additions & 0 deletions projects/github-actions/repo-gardening/src/tasks/flag-oss/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ async function flagOss( payload, octokit ) {
return;
}

// Check if PR author is org member
// https://docs.github.com/en/rest/orgs/members?apiVersion=2022-11-28#check-organization-membership-for-a-user
const orgMembershipRequest = await octokit.rest.orgs.checkMembershipForUser( {
org: owner.login,
username: head.user.login,
} );

if ( 204 === orgMembershipRequest.status ) {
return;
}

debug( `flag-oss: Adding OSS Citizen label to PR #${ number }` );
await octokit.rest.issues.addLabels( {
owner: owner.login,
Expand Down

0 comments on commit be64b86

Please sign in to comment.