Skip to content

Commit

Permalink
Split single quote arg when using GH Action
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 24, 2023
1 parent e60d037 commit 343d717
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"

"github.com/buildkite/shellwords"
"github.com/futurice/jalapeno/internal/cli"
"github.com/gofrs/uuid"
)
Expand All @@ -24,11 +25,17 @@ func main() {
output, err := os.OpenFile(os.Getenv("GITHUB_OUTPUT"), os.O_APPEND|os.O_WRONLY, 0644)
checkErr(err)

// Since arguments are passed as a single string, we need to split them
args, err := shellwords.Split(os.Args[1])
checkErr(err)

delimiter := uuid.Must(uuid.NewV4()).String()
fmt.Fprintf(output, "%s << %s\n", OutputResult, delimiter)
fmt.Fprintf(output, "%s<<%s\n", OutputResult, delimiter)

cmd := cli.NewRootCmd("")
cmd.SetOut(output)
cmd.SetArgs(args)

err = cmd.ExecuteContext(context.Background())
fmt.Fprintf(output, "%s\n", delimiter)

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.1.0 // indirect
github.com/buildkite/shellwords v0.0.0-20180315110454-59467a9b8e10 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiE
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.1.0 h1:9Dpklm2oBBhMxIFbMffmPvDaF7vOYfv9B5HXVr42KMU=
github.com/aymanbagabas/go-udiff v0.1.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/buildkite/shellwords v0.0.0-20180315110454-59467a9b8e10 h1:XwHQ5xDtYPdtBbVPyRO6UZoWZe8/mbKUb076f8x7RvI=
github.com/buildkite/shellwords v0.0.0-20180315110454-59467a9b8e10/go.mod h1:gv0DYOzHEsKgo31lTCDGauIg4DTTGn41Bzp+t3wSOlk=
github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc=
github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8=
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
Expand Down

0 comments on commit 343d717

Please sign in to comment.