Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ MAIL_PORT=587
MAIL_DOMAIN=your_net

# github app
GITHUB_APP_ENABLED=true
GITHUB_ENABLED=true # set false to disable GitHub
GITHUB_APP_ID="GITHUB_APP_ID"
GITHUB_PRIVATE_KEY_PATH="YOUR_PATH"
GITHUB_CLIENT_ID="GITHUB_CLIENT_ID"
Expand Down
12 changes: 11 additions & 1 deletion backend/src/github/github.controller.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
// src/github/github-webhook.controller.ts

import { Body, Controller, Post, Req, Res } from '@nestjs/common';
import { Body, Controller, Logger, Post, Req, Res } from '@nestjs/common';
import { Request, Response } from 'express';
import { createNodeMiddleware } from '@octokit/webhooks';
import { GitHubAppService } from './githubApp.service';
import { GetUserIdFromToken } from 'src/decorator/get-auth-token.decorator';
import { UserService } from 'src/user/user.service';
import { ConfigService } from '@nestjs/config';

@Controller('github')
export class GitHuController {
private readonly logger = new Logger('GitHuController');

private readonly webhookMiddleware;

constructor(
private readonly gitHubAppService: GitHubAppService,
private readonly userService: UserService,
private configService: ConfigService,
) {
const githubEnabled = this.configService.get<string>('GITHUB_ENABLED');
if (githubEnabled !== 'true') {
this.logger.warn('GitHub Controller integration is disabled');
return;
}

// Get the App instance from the service
const app = this.gitHubAppService.getApp();

Expand Down
6 changes: 6 additions & 0 deletions backend/src/github/github.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export class GitHubService {
@InjectRepository(Project)
private projectsRepository: Repository<Project>,
) {
const githubEnabled = this.configService.get<string>('GITHUB_ENABLED');
if (githubEnabled !== 'true') {
this.logger.warn('GitHub service integration is disabled');
return;
}

this.appId = this.configService.get<string>('GITHUB_APP_ID');

const privateKeyPath = this.configService.get<string>(
Expand Down
5 changes: 5 additions & 0 deletions backend/src/github/githubApp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export class GitHubAppService {
@InjectRepository(Project)
private readonly projectRepo: Repository<Project>,
) {
const githubEnabled = this.configService.get<string>('GITHUB_ENABLED');
if (githubEnabled !== 'true') {
this.logger.warn('GitHub APP Service integration is disabled');
return;
}
// Load from environment or config
const appId = this.configService.get('GITHUB_APP_ID');
const privateKeyPath = this.configService.get('GITHUB_PRIVATE_KEY_PATH');
Expand Down
Loading
Loading