improovements

This commit is contained in:
pavel 2026-05-15 00:14:35 +02:00
commit 4205922617
6 changed files with 65 additions and 29 deletions

View file

@ -13,6 +13,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"
)
func (a *App) handleDeployWebhook(w http.ResponseWriter, r *http.Request) {
@ -125,9 +126,21 @@ func (a *App) buildProjectBinaryFromRepoDir(p Project, repoDir string) error {
if err := a.syncStaticAssetsForProject(p); err != nil {
return err
}
commit, err := runCmdOut("git", "-C", repoDir, "rev-parse", "HEAD")
if err != nil {
return fmt.Errorf("resolve latest commit failed: %w", err)
}
if err := a.updateLastDeployment(p.ID, strings.TrimSpace(commit), time.Now().UTC()); err != nil {
return err
}
return nil
}
func (a *App) updateLastDeployment(projectID int64, commit string, deployedAt time.Time) error {
_, err := a.db.Exec(`UPDATE projects SET last_deployed_at=$1, last_deployed_commit=$2 WHERE id=$3`, deployedAt, strings.TrimSpace(commit), projectID)
return err
}
func (a *App) syncProjectRepoFromMain(p Project, projectDir string) error {
repoDir := filepath.Join(projectDir, "repo")
plainRepoURL := strings.TrimSpace(p.RepoURL)