From caf104e2d8a038bf9c6aba750cd5a8510d041bf4 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:49:36 -0700 Subject: [PATCH 1/2] fix: ignore private repositories --- github-app.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/github-app.js b/github-app.js index 221846a..45ea163 100644 --- a/github-app.js +++ b/github-app.js @@ -5,7 +5,7 @@ const GOOD_FIRST_REGEX = /^good\sfirst\sissue$/i; * @param {import("@octokit/app").App} app */ export default async function githubApp(env, app) { - app.log.info('App loaded'); + app.log.info("App loaded"); app.webhooks.onAny(async ({ name, payload }) => { const eventNameWithAction = payload.action ? `${name}.${payload.action}` : name; @@ -13,24 +13,27 @@ export default async function githubApp(env, app) { app.log.info(`Event received: ${eventNameWithAction}`); }); - app.webhooks.on('issues.labeled', async (context) => { - const { name } = context.payload.label; + app.webhooks.on("issues.labeled", async (context) => { + // ignore private repositories + if (context.payload.repository.private) return; + // ignore if label is not "good first issue" + const { name } = context.payload.label; if (!GOOD_FIRST_REGEX.test(name)) return; // send message to discord const discordWebhookUrl = env.DISCORD_WEBHOOKS_URL; const params = { - username: 'GFI-Catsup [beta]', - avatar_url: 'https://github.com/open-sauced/assets/blob/master/logo.png?raw=true', + username: "GFI-Catsup [beta]", + avatar_url: "https://github.com/open-sauced/assets/blob/master/logo.png?raw=true", content: `New good first issue: ${context.payload.issue.html_url}`, }; // send post request using fetch to webhook await fetch(discordWebhookUrl, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", }, body: JSON.stringify(params), }); From 75e628c2a00043d581890fe0a46e8797a793dac0 Mon Sep 17 00:00:00 2001 From: Gregor Martynus <39992+gr2m@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:49:36 -0700 Subject: [PATCH 2/2] style: eslint --- github-app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/github-app.js b/github-app.js index 45ea163..6067dab 100644 --- a/github-app.js +++ b/github-app.js @@ -5,7 +5,7 @@ const GOOD_FIRST_REGEX = /^good\sfirst\sissue$/i; * @param {import("@octokit/app").App} app */ export default async function githubApp(env, app) { - app.log.info("App loaded"); + app.log.info('App loaded'); app.webhooks.onAny(async ({ name, payload }) => { const eventNameWithAction = payload.action ? `${name}.${payload.action}` : name; @@ -13,7 +13,7 @@ export default async function githubApp(env, app) { app.log.info(`Event received: ${eventNameWithAction}`); }); - app.webhooks.on("issues.labeled", async (context) => { + app.webhooks.on('issues.labeled', async (context) => { // ignore private repositories if (context.payload.repository.private) return; @@ -24,16 +24,16 @@ export default async function githubApp(env, app) { // send message to discord const discordWebhookUrl = env.DISCORD_WEBHOOKS_URL; const params = { - username: "GFI-Catsup [beta]", - avatar_url: "https://github.com/open-sauced/assets/blob/master/logo.png?raw=true", + username: 'GFI-Catsup [beta]', + avatar_url: 'https://github.com/open-sauced/assets/blob/master/logo.png?raw=true', content: `New good first issue: ${context.payload.issue.html_url}`, }; // send post request using fetch to webhook await fetch(discordWebhookUrl, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify(params), });