woodpecker-netlify/main.go

43 lines
892 B
Go

package main
import (
"os"
"strconv"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
env "go.jolheiser.com/woodpecker-env"
)
func main() {
app := app()
app.Action = doMain
if err := app.Run(os.Args); err != nil {
log.Err(err).Msg("")
}
}
func doMain(ctx *cli.Context) error {
prIndex, err := strconv.Atoi(env.CI_PULL_REQUEST)
if err != nil {
return err
}
// Netlify deploy
deploy, err := netlifyDeploy(ctx.String("netlify-auth-token"), ctx.String("netlify-site-id"), ctx.String("build-dir"), prIndex)
if err != nil {
return err
}
if err := os.Setenv("FULL_PREVIEW_URL", deploy.DeployURL); err != nil {
return err
}
// Gitea comment
c, err := giteaComment(ctx.String("gitea-url"), ctx.String("gitea-token"), ctx.String("issue-comment"), prIndex)
if err != nil {
return err
}
log.Info().Msgf("Issue Comment created at %s", c.HTMLURL)
return nil
}