run with copy of workingdir

This commit is contained in:
Casey Lee
2020-02-24 17:48:21 -08:00
parent 8f5918942d
commit 1121f6e132
7 changed files with 26 additions and 9 deletions

View File

@@ -82,6 +82,13 @@ func (rc *RunContext) startJobContainer() common.Executor {
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/toolcache"))
binds := []string{
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
}
if rc.Config.BindWorkdir {
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers))
}
rc.JobContainer = container.NewContainer(&container.NewContainerInput{
Cmd: nil,
Entrypoint: []string{"/usr/bin/tail", "-f", "/dev/null"},
@@ -95,10 +102,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
"act-actions": "/actions",
},
Binds: []string{
fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers),
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
},
Binds: binds,
Stdout: logWriter,
Stderr: logWriter,
})
@@ -108,6 +112,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
rc.JobContainer.Remove().IfBool(!rc.Config.ReuseContainers),
rc.JobContainer.Create(),
rc.JobContainer.Start(false),
rc.JobContainer.CopyDir("/github/workspace", rc.Config.Workdir+"/.").IfBool(!rc.Config.BindWorkdir),
rc.JobContainer.Copy("/github/", &container.FileEntry{
Name: "workflow/event.json",
Mode: 644,

View File

@@ -18,6 +18,7 @@ type Runner interface {
// Config contains the config for a new runner
type Config struct {
Workdir string // path to working directory
BindWorkdir bool // bind the workdir to the job container
EventName string // name of event to run
EventPath string // path to JSON file to use for event.json in containers
ReuseContainers bool // reuse containers to maintain state

View File

@@ -160,6 +160,13 @@ func (sc *StepContext) newStepContainer(ctx context.Context, image string, cmd [
envList = append(envList, fmt.Sprintf("%s=%s", "RUNNER_TOOL_CACHE", "/toolcache"))
binds := []string{
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
}
if rc.Config.BindWorkdir {
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers))
}
stepContainer := container.NewContainer(&container.NewContainerInput{
Cmd: cmd,
Entrypoint: entrypoint,
@@ -172,10 +179,7 @@ func (sc *StepContext) newStepContainer(ctx context.Context, image string, cmd [
"act-toolcache": "/toolcache",
"act-actions": "/actions",
},
Binds: []string{
fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers),
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
},
Binds: binds,
Stdout: logWriter,
Stderr: logWriter,
})

View File

@@ -5,6 +5,7 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- run: ls
- run: echo 'hello world'
- run: echo ${GITHUB_SHA} >> /github/sha.txt
- run: cat /github/sha.txt | grep ${GITHUB_SHA}