Api: publish api

This commit is contained in:
nomadics9 2025-01-07 17:32:09 +03:00
parent 2b18269af9
commit 596e96947a

View file

@ -188,7 +188,7 @@ func notify(jsonResponse string) {
defer resp.Body.Close() defer resp.Body.Close()
} }
func TriggerPublish() { func TriggerPublish(c *gin.Context) {
godotenv.Load(".botenv") godotenv.Load(".botenv")
FORGEJO := os.Getenv("FORGEJO_TOKEN") FORGEJO := os.Getenv("FORGEJO_TOKEN")
payload := `{"ref": "main"}` payload := `{"ref": "main"}`
@ -201,6 +201,8 @@ func TriggerPublish() {
client := &http.Client{} client := &http.Client{}
client.Do(req) client.Do(req)
c.Redirect(http.StatusFound, "https://git.askar.tv/nomad/alaskartv-app/actions")
} }
func main() { func main() {
@ -254,10 +256,7 @@ func main() {
}) })
router.POST("/api/publish", func(c *gin.Context) { router.GET("/api/publish", TriggerPublish)
TriggerPublish()
c.JSON(http.StatusOK, gin.H{"message": "Workflow triggered successfully"})
})
router.POST("/notify", notifyHandler) router.POST("/notify", notifyHandler)
router.GET("/", func(c *gin.Context) { router.GET("/", func(c *gin.Context) {