Skip to content

Commit dfbb094

Browse files
feat: custom host env dir for api (#92)
1 parent 0aca9b8 commit dfbb094

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

pkg/runner/run_context.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,18 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
188188
return true
189189
})
190190
cacheDir := rc.ActionCacheDir()
191-
randBytes := make([]byte, 8)
192-
_, _ = rand.Read(randBytes)
193-
miscpath := filepath.Join(cacheDir, hex.EncodeToString(randBytes))
191+
var miscpath string
192+
workdir := rc.Config.HostEnvironmentDir
193+
if workdir == "" {
194+
randBytes := make([]byte, 8)
195+
_, _ = rand.Read(randBytes)
196+
workdir = hex.EncodeToString(randBytes)
197+
}
198+
if filepath.IsAbs(workdir) {
199+
miscpath = workdir
200+
} else {
201+
miscpath = filepath.Join(cacheDir, workdir)
202+
}
194203
actPath := filepath.Join(miscpath, "act")
195204
if err := os.MkdirAll(actPath, 0o777); err != nil {
196205
return err

pkg/runner/runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type Config struct {
6161
Matrix map[string]map[string]bool // Matrix config to run
6262
ContainerNetworkMode docker_container.NetworkMode // the network mode of job containers (the value of --network)
6363
ActionCache ActionCache // Use a custom ActionCache Implementation
64+
HostEnvironmentDir string // Custom folder for host environment, parallel jobs must be 1
6465
}
6566

6667
type caller struct {

0 commit comments

Comments
 (0)