mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(github): use github url to install the application #337
This commit is contained in:
parent
3c8a412014
commit
b7f5bee2f8
@ -9,36 +9,11 @@ import {
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
import { format } from "date-fns";
|
||||||
import { BadgeCheck } from "lucide-react";
|
import { BadgeCheck } from "lucide-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { RemoveGithubApp } from "./remove-github-app";
|
import { RemoveGithubApp } from "./remove-github-app";
|
||||||
export const generateName = () => {
|
|
||||||
const n1 = ["Blue", "Green", "Red", "Orange", "Violet", "Indigo", "Yellow"];
|
|
||||||
const n2 = [
|
|
||||||
"One",
|
|
||||||
"Two",
|
|
||||||
"Three",
|
|
||||||
"Four",
|
|
||||||
"Five",
|
|
||||||
"Six",
|
|
||||||
"Seven",
|
|
||||||
"Eight",
|
|
||||||
"Nine",
|
|
||||||
"Zero",
|
|
||||||
];
|
|
||||||
return `Dokploy-${n1[Math.round(Math.random() * (n1.length - 1))]}-${
|
|
||||||
n2[Math.round(Math.random() * (n2.length - 1))]
|
|
||||||
}`;
|
|
||||||
};
|
|
||||||
function slugify(text: string) {
|
|
||||||
return text
|
|
||||||
.toLowerCase()
|
|
||||||
.replace(/[\s\^&*()+=!]+/g, "-")
|
|
||||||
.replace(/[\$.,*+~()'"!:@^&]+/g, "")
|
|
||||||
.replace(/-+/g, "-")
|
|
||||||
.replace(/^-+|-+$/g, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
export const GithubSetup = () => {
|
export const GithubSetup = () => {
|
||||||
const [isOrganization, setIsOrganization] = useState(false);
|
const [isOrganization, setIsOrganization] = useState(false);
|
||||||
@ -52,10 +27,9 @@ export const GithubSetup = () => {
|
|||||||
const manifest = JSON.stringify(
|
const manifest = JSON.stringify(
|
||||||
{
|
{
|
||||||
redirect_url: `${origin}/api/redirect?authId=${data?.authId}`,
|
redirect_url: `${origin}/api/redirect?authId=${data?.authId}`,
|
||||||
name: generateName(),
|
name: `Dokploy-${format(new Date(), "yyyy-MM-dd")}`,
|
||||||
url: origin,
|
url: origin,
|
||||||
hook_attributes: {
|
hook_attributes: {
|
||||||
// JUST FOR TESTING
|
|
||||||
url: `${url}/api/deploy/github`,
|
url: `${url}/api/deploy/github`,
|
||||||
// url: `${origin}/api/webhook`, // Aquí especificas la URL del endpoint de tu webhook
|
// url: `${origin}/api/webhook`, // Aquí especificas la URL del endpoint de tu webhook
|
||||||
},
|
},
|
||||||
@ -95,8 +69,8 @@ export const GithubSetup = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex items-end gap-4 flex-wrap">
|
<div className="flex items-end gap-4 flex-wrap">
|
||||||
<RemoveGithubApp />
|
<RemoveGithubApp />
|
||||||
{/* <Link
|
<Link
|
||||||
href={`https://github.com/settings/apps/${data?.githubAppName}`}
|
href={`${data?.githubAppName}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className={buttonVariants({
|
className={buttonVariants({
|
||||||
className: "w-fit",
|
className: "w-fit",
|
||||||
@ -104,7 +78,7 @@ export const GithubSetup = () => {
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<span className="text-sm">Manage Github App</span>
|
<span className="text-sm">Manage Github App</span>
|
||||||
</Link> */}
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
@ -119,9 +93,9 @@ export const GithubSetup = () => {
|
|||||||
|
|
||||||
<div className="flex flex-row gap-4">
|
<div className="flex flex-row gap-4">
|
||||||
<Link
|
<Link
|
||||||
href={`https://github.com/apps/${slugify(
|
href={`${
|
||||||
data.githubAppName,
|
data.githubAppName
|
||||||
)}/installations/new?state=gh_setup:${data?.authId}`}
|
}/installations/new?state=gh_setup:${data?.authId}`}
|
||||||
className={buttonVariants({ className: "w-fit" })}
|
className={buttonVariants({ className: "w-fit" })}
|
||||||
>
|
>
|
||||||
Install Github App
|
Install Github App
|
||||||
|
@ -35,7 +35,7 @@ export default async function handler(
|
|||||||
.update(admins)
|
.update(admins)
|
||||||
.set({
|
.set({
|
||||||
githubAppId: data.id,
|
githubAppId: data.id,
|
||||||
githubAppName: data.name,
|
githubAppName: data.html_url,
|
||||||
githubClientId: data.client_id,
|
githubClientId: data.client_id,
|
||||||
githubClientSecret: data.client_secret,
|
githubClientSecret: data.client_secret,
|
||||||
githubWebhookSecret: data.webhook_secret,
|
githubWebhookSecret: data.webhook_secret,
|
||||||
|
Loading…
Reference in New Issue
Block a user