diff --git a/Common/Server/API/GitHubAPI.ts b/Common/Server/API/GitHubAPI.ts index 8ce371ec22..3d6ae47b22 100644 --- a/Common/Server/API/GitHubAPI.ts +++ b/Common/Server/API/GitHubAPI.ts @@ -7,7 +7,7 @@ import Response from "../Utils/Response"; import BadDataException from "../../Types/Exception/BadDataException"; import logger from "../Utils/Logger"; import { JSONObject } from "../../Types/JSON"; -import { DashboardClientUrl, GitHubAppClientId } from "../EnvironmentConfig"; +import { DashboardClientUrl, GitHubAppName } from "../EnvironmentConfig"; import ObjectID from "../../Types/ObjectID"; import GitHubUtil, { GitHubRepository, @@ -116,12 +116,12 @@ export default class GitHubAPI { "/github/auth/install", async (req: ExpressRequest, res: ExpressResponse) => { try { - if (!GitHubAppClientId) { + if (!GitHubAppName) { return Response.sendErrorResponse( req, res, new BadDataException( - "GitHub App is not configured. Please set GITHUB_APP_CLIENT_ID.", + "GitHub App is not configured. Please set GITHUB_APP_NAME.", ), ); } @@ -146,7 +146,7 @@ export default class GitHubAPI { JSON.stringify({ projectId, userId }), ).toString("base64"); - const installUrl: string = `https://github.com/apps/${GitHubAppClientId}/installations/new?state=${state}`; + const installUrl: string = `https://github.com/apps/${GitHubAppName}/installations/new?state=${state}`; return Response.redirect(req, res, URL.fromString(installUrl)); } catch (error) { diff --git a/Common/Server/EnvironmentConfig.ts b/Common/Server/EnvironmentConfig.ts index 8b90d65d48..6f10a14097 100644 --- a/Common/Server/EnvironmentConfig.ts +++ b/Common/Server/EnvironmentConfig.ts @@ -45,6 +45,7 @@ const FRONTEND_ENV_ALLOW_LIST: Array = [ "SLACK_APP_CLIENT_ID", "MICROSOFT_TEAMS_APP_CLIENT_ID", "GITHUB_APP_CLIENT_ID", + "GITHUB_APP_NAME", "CAPTCHA_ENABLED", "CAPTCHA_SITE_KEY", ]; @@ -461,6 +462,8 @@ export const MicrosoftTeamsAppTenantId: string | null = // GitHub App Configuration export const GitHubAppId: string | null = process.env["GITHUB_APP_ID"] || null; +export const GitHubAppName: string | null = + process.env["GITHUB_APP_NAME"] || null; export const GitHubAppClientId: string | null = process.env["GITHUB_APP_CLIENT_ID"] || null; export const GitHubAppClientSecret: string | null = diff --git a/Common/UI/Config.ts b/Common/UI/Config.ts index b322a2a7a0..551ee59e0e 100644 --- a/Common/UI/Config.ts +++ b/Common/UI/Config.ts @@ -256,3 +256,5 @@ export const MicrosoftTeamsAppClientId: string | null = export const GitHubAppClientId: string | null = env("GITHUB_APP_CLIENT_ID") || null; + +export const GitHubAppName: string | null = env("GITHUB_APP_NAME") || null; diff --git a/Dashboard/src/Pages/CodeRepository/CodeRepository.tsx b/Dashboard/src/Pages/CodeRepository/CodeRepository.tsx index 7f26dbee7d..f668aa28dc 100644 --- a/Dashboard/src/Pages/CodeRepository/CodeRepository.tsx +++ b/Dashboard/src/Pages/CodeRepository/CodeRepository.tsx @@ -16,7 +16,7 @@ import React, { useState, } from "react"; import { FormStep } from "Common/UI/Components/Forms/Types/FormStep"; -import { GitHubAppClientId, HOME_URL } from "Common/UI/Config"; +import { GitHubAppName, HOME_URL } from "Common/UI/Config"; import UserUtil from "Common/UI/Utils/User"; import GitHubRepoSelectorModal from "../../Components/CodeRepository/GitHubRepoSelectorModal"; import Button, { ButtonStyleType } from "Common/UI/Components/Button/Button"; @@ -76,7 +76,7 @@ const CodeRepositoryPage: FunctionComponent< setRefreshToggle(Date.now().toString()); }; - const isGitHubAppConfigured: boolean = Boolean(GitHubAppClientId); + const isGitHubAppConfigured: boolean = Boolean(GitHubAppName); return ( <> diff --git a/HelmChart/Public/oneuptime/templates/_helpers.tpl b/HelmChart/Public/oneuptime/templates/_helpers.tpl index 7f6f7db2d6..12ecfd2582 100644 --- a/HelmChart/Public/oneuptime/templates/_helpers.tpl +++ b/HelmChart/Public/oneuptime/templates/_helpers.tpl @@ -55,6 +55,8 @@ Usage: value: {{ $.Values.slackApp.clientId | quote }} - name: GITHUB_APP_ID value: {{ $.Values.gitHubApp.id | quote }} +- name: GITHUB_APP_NAME + value: {{ $.Values.gitHubApp.name | quote }} - name: GITHUB_APP_CLIENT_ID value: {{ $.Values.gitHubApp.clientId | quote }} - name: HOST diff --git a/HelmChart/Public/oneuptime/values.schema.json b/HelmChart/Public/oneuptime/values.schema.json index 40aabcfb27..f10fc584d1 100644 --- a/HelmChart/Public/oneuptime/values.schema.json +++ b/HelmChart/Public/oneuptime/values.schema.json @@ -2062,6 +2062,9 @@ "id": { "type": ["string", "null"] }, + "name": { + "type": ["string", "null"] + }, "clientId": { "type": ["string", "null"] }, diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index a5b975a090..8b83e399e6 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -833,16 +833,18 @@ microsoftTeamsApp: # GitHub Example Configuration # gitHubApp: # id: "123456" +# name: "my-github-app" # clientId: "Iv1.abc123" # clientSecret: "your-client-secret" # privateKey: | # -----BEGIN RSA PRIVATE KEY----- # ... # -----END RSA PRIVATE KEY----- -# webhookSecret: "your-webhook-secret" +# webhookSecret: "your-webhook-secret" gitHubApp: id: + name: clientId: clientSecret: privateKey: diff --git a/config.example.env b/config.example.env index 096127dbcc..7eb6134535 100644 --- a/config.example.env +++ b/config.example.env @@ -360,6 +360,7 @@ MICROSOFT_TEAMS_APP_TENANT_ID= # Create a GitHub App at https://github.com/settings/apps # Required for connecting GitHub repositories to OneUptime GITHUB_APP_ID= +GITHUB_APP_NAME= GITHUB_APP_CLIENT_ID= GITHUB_APP_CLIENT_SECRET= GITHUB_APP_PRIVATE_KEY= diff --git a/docker-compose.base.yml b/docker-compose.base.yml index 6792720c81..48b5b22994 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -142,6 +142,7 @@ x-common-runtime-variables: &common-runtime-variables # GitHub App Configuration GITHUB_APP_ID: ${GITHUB_APP_ID} + GITHUB_APP_NAME: ${GITHUB_APP_NAME} GITHUB_APP_CLIENT_ID: ${GITHUB_APP_CLIENT_ID} GITHUB_APP_CLIENT_SECRET: ${GITHUB_APP_CLIENT_SECRET} GITHUB_APP_PRIVATE_KEY: ${GITHUB_APP_PRIVATE_KEY}