Skip to content

Commit 624b038

Browse files
committed
scripts: keystone: Add command to deploy workflow spec
1 parent a63b381 commit 624b038

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

core/scripts/keystone/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func main() {
2020
src.NewGenerateCribClusterOverridesCommand(),
2121
src.NewDeleteJobsCommand(),
2222
src.NewDeployAndInitializeCapabilitiesRegistryCommand(),
23+
src.NewDeployWorkflowsCommand(),
2324
}
2425

2526
commandsList := func(commands []command) string {
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package src
2+
3+
import (
4+
"bytes"
5+
"errors"
6+
"flag"
7+
"fmt"
8+
"os"
9+
10+
"github.com/urfave/cli"
11+
12+
helpers "github.com/smartcontractkit/chainlink/core/scripts/common"
13+
)
14+
15+
type deployWorkflows struct {
16+
}
17+
18+
func NewDeployWorkflowsCommand() *deployWorkflows {
19+
return &deployWorkflows{}
20+
}
21+
22+
func (g *deployWorkflows) Name() string {
23+
return "deploy-workflows"
24+
}
25+
26+
func (g *deployWorkflows) Run(args []string) {
27+
fs := flag.NewFlagSet(g.Name(), flag.ContinueOnError)
28+
workflowFile := fs.String("workflow", "workflow.yml", "path to workflow file")
29+
err := fs.Parse(args)
30+
if err != nil || workflowFile == nil || *workflowFile == "" {
31+
fs.Usage()
32+
os.Exit(1)
33+
}
34+
fmt.Println("Deploying workflows")
35+
36+
// use a separate list
37+
nodes := downloadNodeAPICredentials(".cache/NodeList.local.txt")
38+
39+
if _, err = os.Stat(*workflowFile); err != nil {
40+
PanicErr(errors.New("toml file does not exist"))
41+
}
42+
43+
for i, n := range nodes {
44+
if i == 0 {
45+
continue // skip bootstrap node
46+
}
47+
output := &bytes.Buffer{}
48+
client, app := newApp(n, output)
49+
fmt.Println("Logging in:", n.url)
50+
loginFs := flag.NewFlagSet("test", flag.ContinueOnError)
51+
loginFs.Bool("bypass-version-check", true, "")
52+
loginCtx := cli.NewContext(app, loginFs, nil)
53+
err := client.RemoteLogin(loginCtx)
54+
helpers.PanicErr(err)
55+
output.Reset()
56+
57+
fmt.Printf("Deploying workflow\n... \n")
58+
fs := flag.NewFlagSet("test", flag.ExitOnError)
59+
err = fs.Parse([]string{*workflowFile})
60+
61+
helpers.PanicErr(err)
62+
err = client.CreateJob(cli.NewContext(app, fs, nil))
63+
if err != nil {
64+
fmt.Println("Failed to deploy workflow:", "Error:", err)
65+
}
66+
output.Reset()
67+
68+
}
69+
}

0 commit comments

Comments
 (0)