fix: #182 - support symlinks in workspace

This commit is contained in:
Casey Lee 2020-04-22 23:24:31 -07:00
parent 6c4e7b9fde
commit 8c290994c1
No known key found for this signature in database
GPG key ID: 1899120ECD0A1784
3 changed files with 10 additions and 2 deletions

View file

@ -350,12 +350,18 @@ func (cr *containerReference) copyDir(dstPath string, srcPath string) common.Exe
}
// return on non-regular files (thanks to [kumo](https://medium.com/@komuw/just-like-you-did-fbdd7df829d3) for this suggested update)
if !fi.Mode().IsRegular() {
linkName := fi.Name()
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
linkName, err = os.Readlink(file)
if err != nil {
return errors.WithMessagef(err, "unable to readlink %s", file)
}
} else if !fi.Mode().IsRegular() {
return nil
}
// create a new dir/file header
header, err := tar.FileInfoHeader(fi, fi.Name())
header, err := tar.FileInfoHeader(fi, linkName)
if err != nil {
return err
}

1
pkg/runner/testdata/workdir/canary-link vendored Symbolic link
View file

@ -0,0 +1 @@
canary

View file

@ -6,6 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: ls -alFt /github/workspace/workdir
- run: '[[ "$(pwd)" == "/github/workspace/workdir" ]]'
working-directory: workdir