feat(github): add triggerType field to GitHub provider and handle tag creation events

This commit is contained in:
Theo D
2025-04-02 22:22:43 +02:00
parent 0bdaa81263
commit fcb8a2bded
6 changed files with 159 additions and 3 deletions

View File

@@ -57,6 +57,7 @@ const GithubProviderSchema = z.object({
branch: z.string().min(1, "Branch is required"),
githubId: z.string().min(1, "Github Provider is required"),
watchPaths: z.array(z.string()).optional(),
triggerType: z.enum(["push", "tag"]).default("push"),
});
type GithubProvider = z.infer<typeof GithubProviderSchema>;
@@ -124,6 +125,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
buildPath: data.buildPath || "/",
githubId: data.githubId || "",
watchPaths: data.watchPaths || [],
triggerType: data.triggerType || "push",
});
}
}, [form.reset, data, form]);
@@ -137,6 +139,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
buildPath: data.buildPath,
githubId: data.githubId,
watchPaths: data.watchPaths || [],
triggerType: data.triggerType,
})
.then(async () => {
toast.success("Service Provided Saved");
@@ -379,6 +382,45 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="triggerType"
render={({ field }) => (
<FormItem>
<div className="flex items-center gap-2">
<FormLabel>Trigger Type</FormLabel>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<HelpCircle className="size-4 text-muted-foreground hover:text-foreground transition-colors cursor-pointer" />
</TooltipTrigger>
<TooltipContent>
<p>
Choose when to trigger deployments: on push to the selected branch or when a new tag is created.
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</div>
<Select
onValueChange={field.onChange}
defaultValue={field.value}
value={field.value}
>
<FormControl>
<SelectTrigger>
<SelectValue placeholder="Select a trigger type" />
</SelectTrigger>
</FormControl>
<SelectContent>
<SelectItem value="push">On Push</SelectItem>
<SelectItem value="tag">On Tag</SelectItem>
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="watchPaths"