use project dir instead of /github/workspace (#567)
This commit is contained in:
parent
6c258cf40d
commit
6cde8f64dc
4 changed files with 20 additions and 21 deletions
|
@ -86,7 +86,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
|
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
|
||||||
}
|
}
|
||||||
if rc.Config.BindWorkdir {
|
if rc.Config.BindWorkdir {
|
||||||
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers))
|
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, rc.Config.Workdir, bindModifiers))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rc.Config.ContainerArchitecture == "" {
|
if rc.Config.ContainerArchitecture == "" {
|
||||||
|
@ -96,12 +96,12 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
rc.JobContainer = container.NewContainer(&container.NewContainerInput{
|
rc.JobContainer = container.NewContainer(&container.NewContainerInput{
|
||||||
Cmd: nil,
|
Cmd: nil,
|
||||||
Entrypoint: []string{"/usr/bin/tail", "-f", "/dev/null"},
|
Entrypoint: []string{"/usr/bin/tail", "-f", "/dev/null"},
|
||||||
WorkingDir: "/github/workspace",
|
WorkingDir: rc.Config.Workdir,
|
||||||
Image: image,
|
Image: image,
|
||||||
Name: name,
|
Name: name,
|
||||||
Env: envList,
|
Env: envList,
|
||||||
Mounts: map[string]string{
|
Mounts: map[string]string{
|
||||||
name: "/github",
|
name: filepath.Dir(rc.Config.Workdir),
|
||||||
"act-toolcache": "/toolcache",
|
"act-toolcache": "/toolcache",
|
||||||
"act-actions": "/actions",
|
"act-actions": "/actions",
|
||||||
},
|
},
|
||||||
|
@ -118,7 +118,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
var copyToPath string
|
var copyToPath string
|
||||||
if !rc.Config.BindWorkdir {
|
if !rc.Config.BindWorkdir {
|
||||||
copyToPath, copyWorkspace = rc.localCheckoutPath()
|
copyToPath, copyWorkspace = rc.localCheckoutPath()
|
||||||
copyToPath = filepath.Join("/github/workspace", copyToPath)
|
copyToPath = filepath.Join(rc.Config.Workdir, copyToPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.NewPipelineExecutor(
|
return common.NewPipelineExecutor(
|
||||||
|
@ -127,7 +127,7 @@ func (rc *RunContext) startJobContainer() common.Executor {
|
||||||
rc.JobContainer.Create(),
|
rc.JobContainer.Create(),
|
||||||
rc.JobContainer.Start(false),
|
rc.JobContainer.Start(false),
|
||||||
rc.JobContainer.CopyDir(copyToPath, rc.Config.Workdir+string(filepath.Separator)+".").IfBool(copyWorkspace),
|
rc.JobContainer.CopyDir(copyToPath, rc.Config.Workdir+string(filepath.Separator)+".").IfBool(copyWorkspace),
|
||||||
rc.JobContainer.Copy("/github/", &container.FileEntry{
|
rc.JobContainer.Copy(filepath.Dir(rc.Config.Workdir), &container.FileEntry{
|
||||||
Name: "workflow/event.json",
|
Name: "workflow/event.json",
|
||||||
Mode: 0644,
|
Mode: 0644,
|
||||||
Body: rc.EventJSON,
|
Body: rc.EventJSON,
|
||||||
|
@ -449,14 +449,14 @@ func (rc *RunContext) getGithubContext() *githubContext {
|
||||||
}
|
}
|
||||||
ghc := &githubContext{
|
ghc := &githubContext{
|
||||||
Event: make(map[string]interface{}),
|
Event: make(map[string]interface{}),
|
||||||
EventPath: "/github/workflow/event.json",
|
EventPath: fmt.Sprintf("%s/%s", filepath.Dir(rc.Config.Workdir), "workflow/event.json"),
|
||||||
Workflow: rc.Run.Workflow.Name,
|
Workflow: rc.Run.Workflow.Name,
|
||||||
RunID: runID,
|
RunID: runID,
|
||||||
RunNumber: runNumber,
|
RunNumber: runNumber,
|
||||||
Actor: rc.Config.Actor,
|
Actor: rc.Config.Actor,
|
||||||
EventName: rc.Config.EventName,
|
EventName: rc.Config.EventName,
|
||||||
Token: token,
|
Token: token,
|
||||||
Workspace: "/github/workspace",
|
Workspace: rc.Config.Workdir,
|
||||||
Action: rc.CurrentStep,
|
Action: rc.CurrentStep,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,9 +580,8 @@ func withDefaultBranch(b string, event map[string]interface{}) map[string]interf
|
||||||
func (rc *RunContext) withGithubEnv(env map[string]string) map[string]string {
|
func (rc *RunContext) withGithubEnv(env map[string]string) map[string]string {
|
||||||
github := rc.getGithubContext()
|
github := rc.getGithubContext()
|
||||||
env["CI"] = "true"
|
env["CI"] = "true"
|
||||||
env["HOME"] = "/github/home"
|
env["HOME"] = fmt.Sprintf("%s/%s", filepath.Dir(rc.Config.Workdir), "home")
|
||||||
|
env["GITHUB_ENV"] = fmt.Sprintf("%s/%s", filepath.Dir(rc.Config.Workdir), "workflow/envs.txt")
|
||||||
env["GITHUB_ENV"] = "/github/workflow/envs.txt"
|
|
||||||
env["GITHUB_WORKFLOW"] = github.Workflow
|
env["GITHUB_WORKFLOW"] = github.Workflow
|
||||||
env["GITHUB_RUN_ID"] = github.RunID
|
env["GITHUB_RUN_ID"] = github.RunID
|
||||||
env["GITHUB_RUN_NUMBER"] = github.RunNumber
|
env["GITHUB_RUN_NUMBER"] = github.RunNumber
|
||||||
|
|
|
@ -160,7 +160,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
|
||||||
}
|
}
|
||||||
scriptName := fmt.Sprintf("workflow/%s", step.ID)
|
scriptName := fmt.Sprintf("workflow/%s", step.ID)
|
||||||
log.Debugf("Wrote command '%s' to '%s'", run, scriptName)
|
log.Debugf("Wrote command '%s' to '%s'", run, scriptName)
|
||||||
containerPath := fmt.Sprintf("/github/%s", scriptName)
|
containerPath := fmt.Sprintf("%s/%s", filepath.Dir(rc.Config.Workdir), scriptName)
|
||||||
|
|
||||||
if step.Shell == "" {
|
if step.Shell == "" {
|
||||||
step.Shell = rc.Run.Job().Defaults.Run.Shell
|
step.Shell = rc.Run.Job().Defaults.Run.Shell
|
||||||
|
@ -169,7 +169,7 @@ func (sc *StepContext) setupShellCommand() common.Executor {
|
||||||
step.Shell = rc.Run.Workflow.Defaults.Run.Shell
|
step.Shell = rc.Run.Workflow.Defaults.Run.Shell
|
||||||
}
|
}
|
||||||
sc.Cmd = strings.Fields(strings.Replace(step.ShellCommand(), "{0}", containerPath, 1))
|
sc.Cmd = strings.Fields(strings.Replace(step.ShellCommand(), "{0}", containerPath, 1))
|
||||||
return rc.JobContainer.Copy("/github/", &container.FileEntry{
|
return rc.JobContainer.Copy(fmt.Sprintf("%s/", filepath.Dir(rc.Config.Workdir)), &container.FileEntry{
|
||||||
Name: scriptName,
|
Name: scriptName,
|
||||||
Mode: 0755,
|
Mode: 0755,
|
||||||
Body: script.String(),
|
Body: script.String(),
|
||||||
|
@ -214,7 +214,7 @@ func (sc *StepContext) newStepContainer(ctx context.Context, image string, cmd [
|
||||||
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
|
fmt.Sprintf("%s:%s", "/var/run/docker.sock", "/var/run/docker.sock"),
|
||||||
}
|
}
|
||||||
if rc.Config.BindWorkdir {
|
if rc.Config.BindWorkdir {
|
||||||
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, "/github/workspace", bindModifiers))
|
binds = append(binds, fmt.Sprintf("%s:%s%s", rc.Config.Workdir, rc.Config.Workdir, bindModifiers))
|
||||||
}
|
}
|
||||||
|
|
||||||
if rc.Config.ContainerArchitecture == "" {
|
if rc.Config.ContainerArchitecture == "" {
|
||||||
|
@ -224,12 +224,12 @@ func (sc *StepContext) newStepContainer(ctx context.Context, image string, cmd [
|
||||||
stepContainer := container.NewContainer(&container.NewContainerInput{
|
stepContainer := container.NewContainer(&container.NewContainerInput{
|
||||||
Cmd: cmd,
|
Cmd: cmd,
|
||||||
Entrypoint: entrypoint,
|
Entrypoint: entrypoint,
|
||||||
WorkingDir: "/github/workspace",
|
WorkingDir: rc.Config.Workdir,
|
||||||
Image: image,
|
Image: image,
|
||||||
Name: createContainerName(rc.jobContainerName(), step.ID),
|
Name: createContainerName(rc.jobContainerName(), step.ID),
|
||||||
Env: envList,
|
Env: envList,
|
||||||
Mounts: map[string]string{
|
Mounts: map[string]string{
|
||||||
rc.jobContainerName(): "/github",
|
rc.jobContainerName(): filepath.Dir(rc.Config.Workdir),
|
||||||
"act-toolcache": "/toolcache",
|
"act-toolcache": "/toolcache",
|
||||||
"act-actions": "/actions",
|
"act-actions": "/actions",
|
||||||
},
|
},
|
||||||
|
@ -299,7 +299,7 @@ func (sc *StepContext) getContainerActionPaths(step *model.Step, actionDir strin
|
||||||
containerActionDir := "."
|
containerActionDir := "."
|
||||||
if step.Type() == model.StepTypeUsesActionLocal {
|
if step.Type() == model.StepTypeUsesActionLocal {
|
||||||
actionName = getOsSafeRelativePath(actionDir, rc.Config.Workdir)
|
actionName = getOsSafeRelativePath(actionDir, rc.Config.Workdir)
|
||||||
containerActionDir = "/github/workspace"
|
containerActionDir = rc.Config.Workdir
|
||||||
} else if step.Type() == model.StepTypeUsesActionRemote {
|
} else if step.Type() == model.StepTypeUsesActionRemote {
|
||||||
actionName = getOsSafeRelativePath(actionDir, rc.ActionCacheDir())
|
actionName = getOsSafeRelativePath(actionDir, rc.ActionCacheDir())
|
||||||
containerActionDir = "/actions"
|
containerActionDir = "/actions"
|
||||||
|
|
4
pkg/runner/testdata/basic/push.yml
vendored
4
pkg/runner/testdata/basic/push.yml
vendored
|
@ -16,8 +16,8 @@ jobs:
|
||||||
args: echo ${INPUT_SOMEKEY} | grep somevalue
|
args: echo ${INPUT_SOMEKEY} | grep somevalue
|
||||||
- run: ls
|
- run: ls
|
||||||
- run: echo 'hello world'
|
- run: echo 'hello world'
|
||||||
- run: echo ${GITHUB_SHA} >> /github/sha.txt
|
- run: echo ${GITHUB_SHA} >> $(dirname "${GITHUB_WORKSPACE}")/sha.txt
|
||||||
- run: cat /github/sha.txt | grep ${GITHUB_SHA}
|
- run: cat $(dirname "${GITHUB_WORKSPACE}")/sha.txt | grep ${GITHUB_SHA}
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check]
|
needs: [check]
|
||||||
|
|
6
pkg/runner/testdata/workdir/push.yml
vendored
6
pkg/runner/testdata/workdir/push.yml
vendored
|
@ -6,12 +6,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: ls -alFt /github/workspace/workdir
|
- run: ls -alFt "${GITHUB_WORKSPACE}/workdir"
|
||||||
- run: '[[ "$(pwd)" == "/github/workspace/workdir" ]]'
|
- run: '[[ "$(pwd)" == "${GITHUB_WORKSPACE}/workdir" ]]'
|
||||||
working-directory: workdir
|
working-directory: workdir
|
||||||
|
|
||||||
noworkdir:
|
noworkdir:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: '[[ "$(pwd)" == "/github/workspace" ]]'
|
- run: '[[ "$(pwd)" == "${GITHUB_WORKSPACE}" ]]'
|
||||||
|
|
Loading…
Add table
Reference in a new issue