Files
ghaymah_dev2 618e74277a
ci / build (push) Canceled after 0s
gy CLI: deploy any directory to a live URL
Commands: login/logout/whoami, deploy (TUI + plain/JSON/CI), logs, status, open, list, version.

- deploy pipeline: tar.gz source (gitignore/dockerignore aware) -> presigned upload -> cloud kaniko/buildpacks build -> live URL
- bubbletea/lipgloss TUI with upload progress + live log streaming; auto-falls-back to plain output in CI
- apiclient against the gateway /v1/deployments + /v1/apps endpoints
- GitHub Action (action.yml) + example workflow + install script
2026-10-24 05:18:43 -04:00

52 lines
1.1 KiB
Go

package cli
import (
"context"
"errors"
"os"
"gitlab.com/ghaymah/gy/internal/apiclient"
"gitlab.com/ghaymah/gy/internal/gyconfig"
)
// resolveApp finds the app the current directory is linked to (by the CI
// project tag), or falls back to a --name match / the only app.
func resolveApp(c *apiclient.Client, dir, name string) (*apiclient.App, error) {
apps, err := c.ListApps(context.Background())
if err != nil {
return nil, err
}
var candidates []apiclient.App
for _, a := range apps {
if a.Ephemeral {
continue // skip CI build workers
}
candidates = append(candidates, a)
}
if l, lerr := gyconfig.LoadLink(dir); lerr == nil && l.ProjectID != "" {
for i := range candidates {
if candidates[i].Tags["ci.project_id"] == l.ProjectID {
return &candidates[i], nil
}
}
}
if name != "" {
for i := range candidates {
if candidates[i].Name == name {
return &candidates[i], nil
}
}
}
if len(candidates) == 1 {
return &candidates[0], nil
}
return nil, errors.New("no linked app found — run `gy deploy` or pass --name")
}
func cwd() string {
d, _ := os.Getwd()
return d
}