Skip to content

Commit

Permalink
require
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 11, 2024
1 parent 18c6751 commit 87cdcf3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/supersetbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
const cmd = context.eventName === 'workflow_dispatch'
? context.payload.inputs.comment_body
: context.payload.comment.body;
const modulePath = '.github/workflows/supersetbot/src/index.js';
const githubWorkspace = process.env.GITHUB_WORKSPACE;
const modulePath = `${githubWorkspace}/.github/workflows/supersetbot/src/index.js`;
const { runCliCommand } = await import(modulePath);
runCliCommand(cmd);
})();
35 changes: 15 additions & 20 deletions .github/workflows/supersetbot/src/commands.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ORG_LIST } from './metadata.js';
/* eslint-disable no-shadow */

export function commandWrapper(commandFunc, context, verbose = false) {
Expand Down Expand Up @@ -48,30 +49,24 @@ export function unlabel(repo, issueNumber, label, github) {
});
}

export async function assignOrgLabel(issueNumber, github) {
export async function assignOrgLabel(repo, issueNumber, github) {

const username = issue.user.login;
const issue = await github.rest.issues.get({
...unPackRepo(repo),
issue_number: issueNumber,
});

const username = issue.data.user.login;
const orgs = await github.orgs.listForUser({ username });
const orgNames = orgs.data.map(v => v.login);

// get list of matching github orgs
let matchingOrgs = orgNames.filter(org => conf.ORG_WHITELIST.includes(org));
// append user-based orgs from list
if (conf.USER_ORG_XREF[username]) {
matchingOrgs.push(conf.USER_ORG_XREF[username]);
let matchingOrgs = orgNames.filter(org => ORG_LIST.includes(org));
if (matchingOrgs.length) {
return github.rest.issues.addLabels({
...unPackRepo(repo),
issue_number: issueNumber,
labels: [matchingOrgs],
});
}
// look up org groups, add 'em in!
const orgGroups = [];
matchingOrgs.forEach(org => {
if (conf.ORG_GROUPS[org]) {
orgGroups.push(conf.ORG_GROUPS[org]);
}
});
matchingOrgs.concat(orgGroups);
// dedupe, just in case
matchingOrgs = new Set(matchingOrgs);
matchingOrgs.forEach(org => {
return github.issues.addLabels(
context.issue({ issue_number: issue.number, labels: [org] }));
});
}

0 comments on commit 87cdcf3

Please sign in to comment.