improovements
This commit is contained in:
parent
fa7f791873
commit
4205922617
6 changed files with 65 additions and 29 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue