Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behavior when syncing two directories #15

Closed
BetaHuhn opened this issue Mar 18, 2021 · 1 comment
Closed

Weird behavior when syncing two directories #15

BetaHuhn opened this issue Mar 18, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@BetaHuhn
Copy link
Owner

BetaHuhn commented Mar 18, 2021

🐞 Describe the bug

I noticed a weird behavior when trying to sync two directories like this:

user/repo:
  - source: .github/ISSUE_TEMPLATE/
    dest: issues/

If issues/ already exists, the files from .github/ISSUE_TEMPLATE/ end up in issues/ISSUE_TEMPLATE/ instead of in issues/ as you would expect.

After investigating I found that the package used to copy files in this action, @actions/io, creates a new folder from the basename of the source path and copys the source files into it when the target directory already exists.

Here are the lines responsible for this behavior:

  // If dest is an existing directory, should copy inside.
  const newDest: string =
    destStat && destStat.isDirectory()
      ? path.join(dest, path.basename(source))
      : dest

From: https://github.com/actions/toolkit/blob/4dd900dde00dcc90e5c649b688c643b1fc7684a2/packages/io/src/io.ts#L47-L51

📋 Additional context

I filed an issue (#741) in GitHub's Actions Toolkit repo and will wait a bit for their response. If this doesn't get addressed in a reasonable amount of time I will use another library, or the shell directly, to copy files/directories in this action.

Please let me know if you run into this problem as well or if you have another idea for a solution. Thanks!

@BetaHuhn BetaHuhn added bug Something isn't working help wanted Extra attention is needed labels Mar 18, 2021
@BetaHuhn BetaHuhn self-assigned this Mar 18, 2021
@BetaHuhn BetaHuhn pinned this issue Mar 18, 2021
@BetaHuhn BetaHuhn unpinned this issue Apr 16, 2021
@BetaHuhn BetaHuhn removed the help wanted Extra attention is needed label Apr 16, 2021
@BetaHuhn
Copy link
Owner Author

Fixed by using node-fs-extra instead of @actions/io to copy files internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant