Skip to content

Commit

Permalink
Support custom AsyncAPI owners
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Aug 2, 2024
1 parent 255d2e7 commit fde9775
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions .github/scripts/maintainers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,33 @@ function getCommaSeparatedInputList(list) {
);
}

function splitByWhitespace(line) {
return line.trim().split(/\s+/);
}

function extractGitHubUsernames(codeownersContent, core) {
if (!codeownersContent) {
return [];
}
if (!codeownersContent) return [];

const uniqueOwners = new Set();

for (const line of codeownersContent.split("\n")) {
// extract any data that is before the '#' char and trim whitespace
const trimmedLine = line.split("#")[0].trim();
// split by '#' to process comments separately
const [ownersLine, comment = ""] = line.split("#");

// 1. Check AsyncAPI custom owners
const triagers = comment.split(/docTriagers:|codeTriagers:/)[1]
if (triagers) {
const owners = splitByWhitespace(triagers)
owners.forEach(owner => uniqueOwners.add(owner))
}

// split by whitespace to get the owners
const owners = trimmedLine.split(/\s+/);
// 2. Check GitHub native codeowners
const owners = splitByWhitespace(ownersLine);

// the 1st element is the file location, we don't need it, so we start with 2nd item
for (const owner of owners.slice(1)) {
if (!owner.startsWith("@") || owner.includes("/")) {
core.warning(
`Skipping '${owner}' as emails and teams are not supported yet`,
);
core.warning(`Skipping '${owner}' as emails and teams are not supported yet`);
continue;
}
uniqueOwners.add(owner.slice(1)); // remove the '@'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-maintainers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- '.github/workflows/update-maintainers.yaml'

schedule:
- cron: "0 0 * * MON" # Runs at 10:00 AM UTC every Monday.
- cron: "0 10 * * SUN" # Runs at 10:00 AM UTC every Sunday.

workflow_dispatch:

Expand Down

0 comments on commit fde9775

Please sign in to comment.