Have got publishing to Netlify

This commit is contained in:
Leon Mika 2025-01-27 15:45:53 +11:00
parent 8e0ffb6c24
commit 7ef6725bdb
23 changed files with 667 additions and 109 deletions

View file

@ -0,0 +1,29 @@
package netlify
import (
"context"
"fmt"
"lmika.dev/lmika/hugo-crm/models"
"os"
"os/exec"
)
type Provider struct {
authToken string
}
func New(authToken string) *Provider {
return &Provider{
authToken: authToken,
}
}
func (p *Provider) Publish(ctx context.Context, target models.PublishTarget, dir string) error {
cmd := exec.CommandContext(ctx, "netlify", "deploy", "--dir", dir, "--prod")
cmd.Env = append(os.Environ(),
fmt.Sprintf("NETLIFY_SITE_ID=%v", target.TargetRef),
fmt.Sprintf("NETLIFY_AUTH_TOKEN=%v", p.authToken))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}