asf
This commit is contained in:
parent
07522043b4
commit
22c2f68c2a
3 changed files with 30 additions and 11 deletions
|
|
@ -110,10 +110,24 @@ func (a *App) provisionProject(ctx context.Context, p *Project) error {
|
|||
}
|
||||
repoURL, err := a.createForgejoRepo(ctx, p.Slug, p.Description, p.RepoPrivate)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "status=409") {
|
||||
owner := strings.TrimSpace(a.cfg.ForgejoOrg)
|
||||
if owner == "" {
|
||||
owner = p.UserID
|
||||
}
|
||||
repoURL = strings.TrimRight(a.cfg.ForgejoBaseURL, "/") + "/" + owner + "/" + p.Slug
|
||||
} else {
|
||||
_ = a.updateProvisioningState(ctx, p.ID, "failed", err.Error())
|
||||
p.ProvisionState = "failed"
|
||||
p.ProvisionError = err.Error()
|
||||
return err
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(repoURL) == "" {
|
||||
_ = a.updateProvisioningState(ctx, p.ID, "failed", err.Error())
|
||||
p.ProvisionState = "failed"
|
||||
p.ProvisionError = err.Error()
|
||||
return err
|
||||
return errors.New("forgejo repo url is empty after provisioning")
|
||||
}
|
||||
p.RepoURL = repoURL
|
||||
if _, err := a.db.ExecContext(ctx, `UPDATE projects SET repo_url=$1 WHERE id=$2`, repoURL, p.ID); err != nil {
|
||||
|
|
@ -129,15 +143,6 @@ func (a *App) provisionProject(ctx context.Context, p *Project) error {
|
|||
p.ProvisionError = err.Error()
|
||||
return err
|
||||
}
|
||||
if p.RepoURL != "" {
|
||||
if err := a.buildProjectBinary(*p); err != nil {
|
||||
_ = a.updateProvisioningState(ctx, p.ID, "failed", err.Error())
|
||||
p.ProvisionState = "failed"
|
||||
p.ProvisionError = err.Error()
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.renderSystemdForProject(ctx, *p); err != nil {
|
||||
_ = a.updateProvisioningState(ctx, p.ID, "failed", err.Error())
|
||||
p.ProvisionState = "failed"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue