Skip to content

Commit

Permalink
fix: ignore private repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Aug 16, 2023
1 parent 2bfb0f8 commit caf104e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions github-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@ 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");

Check warning on line 8 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 8 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

app.webhooks.onAny(async ({ name, payload }) => {
const eventNameWithAction = payload.action ? `${name}.${payload.action}` : name;

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) => {

Check warning on line 16 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 16 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote
// 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]",

Check warning on line 27 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 27 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote
avatar_url: "https://github.com/open-sauced/assets/blob/master/logo.png?raw=true",

Check warning on line 28 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 28 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote
content: `New good first issue: ${context.payload.issue.html_url}`,
};

// send post request using fetch to webhook
await fetch(discordWebhookUrl, {
method: 'POST',
method: "POST",

Check warning on line 34 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 34 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",

Check warning on line 36 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 36 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 36 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote

Check warning on line 36 in github-app.js

View workflow job for this annotation

GitHub Actions / test / Code standards

Strings must use singlequote
},
body: JSON.stringify(params),
});
Expand Down

0 comments on commit caf104e

Please sign in to comment.