exclude dependabot from commmunity contributor label (#44861)

* exclude dependabot from commmunity contributor label

* use prior art from block repo

---------

Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
Ron Rennick 2024-02-22 15:37:07 -04:00 committed by GitHub
parent 6524f639b4
commit d1afc4abe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -6,6 +6,10 @@ const core = require( '@actions/core' );
// this won't work.
const octokit = new Octokit();
const ignoredUsernames = [ 'dependabot[bot]' ];
const checkIfIgnoredUsername = ( username ) =>
ignoredUsernames.includes( username );
const getIssueAuthor = ( payload ) => {
return (
payload?.issue?.user?.login ||
@ -15,7 +19,7 @@ const getIssueAuthor = ( payload ) => {
};
const isCommunityContributor = async ( owner, repo, username ) => {
if ( username ) {
if ( username && ! checkIfIgnoredUsername( username ) ) {
const {
data: { permission },
} = await octokit.rest.repos.getCollaboratorPermissionLevel( {
@ -27,6 +31,7 @@ const isCommunityContributor = async ( owner, repo, username ) => {
return permission === 'read' || permission === 'none';
}
console.log( 'Not a community contributor!' );
return false;
};