Skip to content

Commit

Permalink
Removes default 30-minute timeout from gh-trigger-workflow (gravita…
Browse files Browse the repository at this point in the history
…tional#24178)

The `gh-trigger-workflow` will now default to waiting forever for a
GitHub Workflow to complete. A timeout can be optionally specified
if desired.
  • Loading branch information
tcsc authored Apr 11, 2023
1 parent ceb61f5 commit 75395e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.assets/tooling/cmd/gh-trigger-workflow/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func parseCommandLine() (args, error) {
flag.StringVar(&cliArgs.workflow, "workflow", "", "Path to workflow")
flag.StringVar(&cliArgs.workflowRef, "workflow-ref", cliArgs.workflowRef, "Revision reference")
flag.BoolVar(&cliArgs.useWorkflowTag, "tag-workflow", false, "Use a workflow input to tag and ID workflows spawned by the event")
flag.DurationVar(&cliArgs.timeout, "timeout", 30*time.Minute, "Timeout")
flag.DurationVar(&cliArgs.timeout, "timeout", time.Duration(0), "Timeout. If not specified, waits forever.")
flag.Var(cliArgs.inputs, "input", "Input to target workflow")

flag.Parse()
Expand Down
10 changes: 8 additions & 2 deletions build.assets/tooling/cmd/gh-trigger-workflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ func main() {
log.Fatal(err.Error())
}

ctx, cancel := context.WithTimeout(context.Background(), args.timeout)
defer cancel()
ctx := context.Background()
if args.timeout != 0 {
log.Printf("Setting %v timeout", args.timeout)

var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, args.timeout)
defer cancel()
}

installationID, err := lookupInstallationID(ctx, args)
if err != nil {
Expand Down

0 comments on commit 75395e3

Please sign in to comment.