Skip to content

Commit

Permalink
Limit docs_parenting and hacktoberfest (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Sep 22, 2022
1 parent c05ba5e commit 92baa46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions services/bots/src/github-webhook/github-webhook.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum Repository {
BRANDS = 'brands',
CORE = 'core',
DEVELOPERS_HOME_ASSISTANT = 'developers.home-assistant',
FRONTEND = 'frontend',
HOME_ASSISTANT_IO = 'home-assistant.io',
}

Expand Down
5 changes: 4 additions & 1 deletion services/bots/src/github-webhook/handlers/docs_parenting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export class DocsParenting extends BaseWebhookHandler {
'pull_request.closed',
'pull_request.opened',
'pull_request.edited',
].includes(context.eventType)
].includes(context.eventType) ||
![Repository.CORE, Repository.HOME_ASSISTANT_IO, Repository.FRONTEND].includes(
context.repo().repo as Repository,
)
) {
return;
}
Expand Down
8 changes: 8 additions & 0 deletions services/bots/src/github-webhook/handlers/hacktoberfest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { PullRequestClosedEvent } from '@octokit/webhooks-types';
import { Repository } from '../github-webhook.const';
import { WebhookContext } from '../github-webhook.model';
import { BaseWebhookHandler } from './base';

export const isHacktoberfestLive = () => new Date().getMonth() === 9;

export class Hacktoberfest extends BaseWebhookHandler {
async handle(context: WebhookContext<any>) {
if (
![Repository.CORE, Repository.HOME_ASSISTANT_IO, Repository.FRONTEND].includes(
context.repo().repo as Repository,
)
) {
return;
}
if (isHacktoberfestLive && context.eventType === 'pull_request.opened') {
await this.handlePullRequestOpened(context);
} else if (context.eventType === 'pull_request.closed') {
Expand Down

0 comments on commit 92baa46

Please sign in to comment.