diff --git a/helpers/github.ts b/helpers/github.ts index 42d76e68..e4154aa0 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -62,6 +62,22 @@ export async function forceCloseMissingIssues(devpoolIssues: GitHubIssue[], proj } } +/** + * Stops forks from spamming real Ubiquity issues with links to their forks + * @returns true if the authenticated user is Ubiquity + */ +export async function checkIfForked() { + try { + const { + data: { id }, + } = await octokit.users.getAuthenticated(); + return id !== 76412717; + } catch (e: unknown) { + console.warn(`Getting authenticated user failed: ${e}`); + return false; + } +} + /** * Returns all issues in a repo * @param ownerName owner name diff --git a/index.ts b/index.ts index e5c25b27..09c92646 100644 --- a/index.ts +++ b/index.ts @@ -12,6 +12,7 @@ import { getSocialMediaText, GitHubIssue, GitHubLabel, + checkIfForked, LABELS, octokit, } from "./helpers/github"; @@ -35,6 +36,8 @@ async function main() { // aggregate all project issues const allProjectIssues: GitHubIssue[] = []; + const isFork = await checkIfForked(); + // for each project URL for (const projectUrl of projectUrls) { // get owner and repository names from project URL @@ -47,6 +50,8 @@ async function main() { for (const projectIssue of projectIssues) { // if issue exists in devpool const devpoolIssue = getIssueByLabel(devpoolIssues, `id: ${projectIssue.node_id}`); + const body = isFork ? projectIssue.html_url.replace("https://github.com", "https://www.github.com") : projectIssue.html_url; + if (devpoolIssue) { // If project issue doesn't have the "Price" label (i.e. it has been removed) then close // the devpool issue if it is not already closed, no need to pollute devpool repo with draft issues @@ -90,7 +95,7 @@ async function main() { repo: DEVPOOL_REPO_NAME, issue_number: devpoolIssue.number, title: projectIssue.title, - body: projectIssue.html_url, + body, state: projectIssue.state as "open" | "closed", labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); @@ -104,12 +109,13 @@ async function main() { if (projectIssue.state === "closed") continue; // if issue doesn't have the "Price" label then skip it, no need to pollute repo with draft issues if (!(projectIssue.labels as GitHubLabel[]).some((label) => label.name.includes(LABELS.PRICE))) continue; + // create a new issue const createdIssue = await octokit.rest.issues.create({ owner: DEVPOOL_OWNER_NAME, repo: DEVPOOL_REPO_NAME, title: projectIssue.title, - body: projectIssue.html_url, + body, labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); console.log(`Created: ${createdIssue.data.html_url} (${projectIssue.html_url})`); diff --git a/opt.json b/opt.json index 648f519a..1a0df256 100644 --- a/opt.json +++ b/opt.json @@ -7,16 +7,15 @@ "ubiquity/devpool-directory", "ubiquity/card-issuance", "ubiquity/research", + "ubiquity/recruiting", "ubiquity/business-development", "ubiquity/ubiquibar", "ubiquity/ubiquibot", "ubiquity/ubiquibot-telegram", - "ubiquibot/configuration", - "ubiquibot/comment-incentives", "ubiquibot/production", "ubiquibot/sandbox", "ubiquibot/e2e-tests", "ubiquibot/staging" ] -} +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b3a7aa81..9ca2add1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1057,7 +1057,7 @@ resolved "https://registry.yarnpkg.com/@mswjs/cookies/-/cookies-1.1.0.tgz#1528eb43630caf83a1d75d5332b30e75e9bb1b5b" integrity sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw== -"@mswjs/data@^0.16.1": +"@mswjs/data@0.16.1": version "0.16.1" resolved "https://registry.yarnpkg.com/@mswjs/data/-/data-0.16.1.tgz#ee41b95b8f2e954a07b0eb54154592a2459064d1" integrity sha512-VhJvL/VmgAuU9/tDOcKcxHfNd+8nxYntZnrkaQEQPvZZnFwQQR9bzI1FTRROGxCHVoyfv9v84AEkl/7CIw4FAg==