From 596e96947ac9db6fb9e7c09fefab92ed9a0ef19c Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Tue, 7 Jan 2025 17:32:09 +0300 Subject: [PATCH] Api: publish api --- main.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 21ea049..768dba7 100644 --- a/main.go +++ b/main.go @@ -188,7 +188,7 @@ func notify(jsonResponse string) { defer resp.Body.Close() } -func TriggerPublish() { +func TriggerPublish(c *gin.Context) { godotenv.Load(".botenv") FORGEJO := os.Getenv("FORGEJO_TOKEN") payload := `{"ref": "main"}` @@ -201,6 +201,8 @@ func TriggerPublish() { client := &http.Client{} client.Do(req) + c.Redirect(http.StatusFound, "https://git.askar.tv/nomad/alaskartv-app/actions") + } func main() { @@ -254,10 +256,7 @@ func main() { }) - router.POST("/api/publish", func(c *gin.Context) { - TriggerPublish() - c.JSON(http.StatusOK, gin.H{"message": "Workflow triggered successfully"}) - }) + router.GET("/api/publish", TriggerPublish) router.POST("/notify", notifyHandler) router.GET("/", func(c *gin.Context) {