Have got publishing to Netlify
This commit is contained in:
parent
8e0ffb6c24
commit
7ef6725bdb
23 changed files with 667 additions and 109 deletions
29
providers/netlify/provider.go
Normal file
29
providers/netlify/provider.go
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue