remove .gitignore before docker cp (#288)
* Test setup before I try to understand how things work * Remove .gitignore before we run docker cp
This commit is contained in:
parent
d4e41a90a2
commit
7cc668707b
3 changed files with 38 additions and 1 deletions
|
@ -53,6 +53,7 @@ func TestRunEvent(t *testing.T) {
|
||||||
{"matrix", "push", ""},
|
{"matrix", "push", ""},
|
||||||
{"commands", "push", ""},
|
{"commands", "push", ""},
|
||||||
{"workdir", "push", ""},
|
{"workdir", "push", ""},
|
||||||
|
{"issue-228", "push", ""}, // TODO [igni]: Remove this once everything passes
|
||||||
}
|
}
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -266,7 +267,11 @@ func (sc *StepContext) runAction(actionDir string, actionPath string) common.Exe
|
||||||
switch action.Runs.Using {
|
switch action.Runs.Using {
|
||||||
case model.ActionRunsUsingNode12:
|
case model.ActionRunsUsingNode12:
|
||||||
if step.Type() == model.StepTypeUsesActionRemote {
|
if step.Type() == model.StepTypeUsesActionRemote {
|
||||||
err := rc.JobContainer.CopyDir(containerActionDir+string(filepath.Separator), actionDir)(ctx)
|
err := removeGitIgnore(actionDir)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = rc.JobContainer.CopyDir(containerActionDir+string(filepath.Separator), actionDir)(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -351,3 +356,20 @@ func newRemoteAction(action string) *remoteAction {
|
||||||
}
|
}
|
||||||
return ra
|
return ra
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/nektos/act/issues/228#issuecomment-629709055
|
||||||
|
// files in .gitignore are not copied in a Docker container
|
||||||
|
// this causes issues with actions that ignore other important resources
|
||||||
|
// such as `node_modules` for example
|
||||||
|
func removeGitIgnore(directory string) error {
|
||||||
|
gitIgnorePath := path.Join(directory, ".gitignore")
|
||||||
|
if _, err := os.Stat(gitIgnorePath); err == nil {
|
||||||
|
// .gitignore exists
|
||||||
|
log.Debugf("Removing %s before docker cp", gitIgnorePath)
|
||||||
|
err := os.Remove(gitIgnorePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
14
pkg/runner/testdata/issue-228/main.yaml
vendored
Normal file
14
pkg/runner/testdata/issue-228/main.yaml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: issue-228
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
kind:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: apt-get update -y && apt-get install git -y # setup git credentials will fail otherwise
|
||||||
|
- name: Setup git credentials
|
||||||
|
uses: fusion-engineering/setup-git-credentials@v2
|
||||||
|
with:
|
||||||
|
credentials: https://test@github.com/
|
Loading…
Add table
Reference in a new issue