-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.go
109 lines (101 loc) · 2 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"context"
"log"
"os"
"time"
"dagger.io/dagger"
"github.com/urfave/cli/v2"
)
func main() {
ctx := context.Background()
dag, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
panic(err)
}
defer dag.Close()
app := &cli.App{
Name: "nightly",
Usage: "Changelog Nightly CI/CD pipeline commands",
Version: "v2023.10.10",
Compiled: time.Now(),
Authors: []*cli.Author{
{
Name: "Jerod Santo",
Email: "[email protected]",
},
{
Name: "Gerhard Lazu",
Email: "[email protected]",
},
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "nocache",
Aliases: []string{"n"},
Usage: "Bust Dagger ops cache",
EnvVars: []string{"NOCACHE"},
},
&cli.BoolFlag{
Name: "debug",
Aliases: []string{"d"},
Usage: "Debug command",
EnvVars: []string{"DEBUG"},
},
&cli.StringFlag{
Name: "platform",
Aliases: []string{"p"},
Usage: "Runtime platform",
Value: "linux/amd64",
EnvVars: []string{"PLATFORM"},
},
},
Commands: []*cli.Command{
{
Name: "build",
Aliases: []string{"b"},
Usage: "Builds container image",
Action: func(cCtx *cli.Context) error {
newPipeline(ctx, cCtx, dag).
Build()
return nil
},
},
{
Name: "test",
Aliases: []string{"t"},
Usage: "Runs tests",
Action: func(cCtx *cli.Context) error {
newPipeline(ctx, cCtx, dag).
Build().
Test()
return nil
},
},
{
Name: "cicd",
Usage: "Runs the entire CI/CD pipeline",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "app",
Aliases: []string{"a"},
Usage: "Fly.io app name",
EnvVars: []string{"APP"},
Required: true,
},
},
Action: func(cCtx *cli.Context) error {
newPipeline(ctx, cCtx, dag).
Build().
Test().
Prod().
Deploy()
return nil
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}