-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathaction.go
More file actions
33 lines (27 loc) · 714 Bytes
/
action.go
File metadata and controls
33 lines (27 loc) · 714 Bytes
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
package main
import (
"context"
_ "embed"
"fmt"
"os"
"os/exec"
"strings"
"go.bobheadxi.dev/streamline/streamexec"
)
//go:embed entrypoint.sh
var entrypointScript string
// runEmbeddedAction executes an embedded version of entrypoint.sh
func runEmbeddedAction(ctx context.Context) error {
cmd := exec.CommandContext(ctx, "bash")
cmd.Stdin = strings.NewReader(entrypointScript)
cmd.Env = os.Environ()
if executable, err := os.Executable(); err == nil {
cmd.Env = append(cmd.Env, fmt.Sprintf("GOBENCHDATA_BINARY=%s", executable))
}
stream, err := streamexec.Start(cmd, streamexec.Stdout|streamexec.ErrWithStderr)
if err != nil {
return err
}
_, err = stream.WriteTo(os.Stdout)
return err
}