Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo Gardening: check if PR owner is a member of the org to determine if they're an OSS Citizen #36860

Merged
merged 5 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ async function flagOss( payload, octokit ) {
const { head, base } = pull_request;
const { owner, name } = repository;

if ( head.repo.full_name === base.repo.full_name ) {
// 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 ( head.repo.full_name === base.repo.full_name || 204 === orgMembershipRequest.status ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, that would be a good addition I think.

That said, I wonder if we could save an API call in most scenarios, by keeping the 2 checks separate?

  1. We would start by checking if the PR is from a branch in the same remote, like we do today. If yes we bail, like today.
  2. Then, only when the PR is from a different remote we make the API call you're introducing here to figure out if the PR author is a member of the organization.

I believe it would avoid slowing things down for most of the PRs today.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Applied on 703a0b0

return;
}

Expand Down
Loading