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

Can not upload a directory that is a symlink to a directory #92

Open
2 of 6 tasks
arianvp opened this issue Jul 6, 2020 · 12 comments · Fixed by actions/toolkit#1190
Open
2 of 6 tasks

Can not upload a directory that is a symlink to a directory #92

arianvp opened this issue Jul 6, 2020 · 12 comments · Fixed by actions/toolkit#1190
Labels
bug Something isn't working

Comments

@arianvp
Copy link

arianvp commented Jul 6, 2020

Describe the bug
The nix package manager drops a symlink to the build artifact in your local directory called result which links
to the content-adressed build-directory e.g.:

lrwxrwxrwx 1 arian users 50 Jul  6 15:10 result -> /nix/store/qk0wg6wv073bz78llr582by4x3n59kgk-jekyll

but uploading that directory fails using the following workflow:

    - name: "Build"
      run: nix-build -A website
    - name: "Upload artifact to github"
      uses: actions/upload-artifact@v2
      with:
        name: website
        path: result/**/*

However as a workaround, if you create a directory inside that symlink then it does work:

    - name: "Build"
      run: nix-build -A website
    - name: "Upload artifact to github"
      uses: actions/upload-artifact@v2
      with:
        name: website
        path: result/dummy-directory/**/*

Version

  • V1
  • V2

Environment

  • self-hosted
  • Linux
  • Windows
  • Mac

Screenshots
If applicable, add screenshots to help explain your problem.

Run/Repo Url
https://github.com/minvws/nl-covid19-notification-app-community-website/runs/841910187?check_suite_focus=true

How to reproduce
If applicable, add information on how to reproduce the problem.

Additional context
Add any other context about the problem here.

@arianvp arianvp added the bug Something isn't working label Jul 6, 2020
@arianvp
Copy link
Author

arianvp commented Jul 6, 2020

Funnily enough; the code does detect that it's a directory, and even tells me how many files will be uploaded; to only later fail:

With the provided path, there will be 11 files uploaded
##[error]Provided rootDirectory /home/runner/work/nl-covid19-notification-app-community-website/nl-covid19-notification-app-community-website/result is not a valid directory

The fix seems like we should first resolve symlinks before checking with lstat whether the file is a directory

@rpearce
Copy link

rpearce commented Sep 14, 2020

Same issue here: https://github.com/rpearce/robertwpearce.com/pull/68/checks?check_run_id=1109884668

@arianvp Is the workaround to have a directory inside the symlinked dir?

Edit: Yes, that worked for me.

eadwu added a commit to CSE-Courses/course-project-a3-massive-muscles that referenced this issue Oct 9, 2020
eadwu added a commit to CSE-Courses/course-project-a3-massive-muscles that referenced this issue Oct 9, 2020
eadwu added a commit to CSE-Courses/course-project-a3-massive-muscles that referenced this issue Oct 9, 2020
@grigorye
Copy link

grigorye commented Oct 18, 2020

Just in case, another workaround (that works in my case) might be using glob pattern instead of the exact name for the directory. Given the orginal example, something like this:

    - name: "Upload artifact to github"
      uses: actions/upload-artifact@v2
      with:
        name: website
        path: result*/**/*

In case the glob does match extra (irrelevant) directories, I wonder if you could use ! to filter out non-related stuff e.g. like below:

    - name: "Upload artifact to github"
      uses: actions/upload-artifact@v2
      with:
        name: website
        path: |
          result*/**/*
          !result?*

@gebn
Copy link

gebn commented Nov 9, 2020

I'm also running into this with Bazel, which symlinks bazel-bin in the workspace directory:

- uses: actions/upload-artifact@v2
  with:
    name: archive
    path: bazel-bin/archive.tar.gz
Run actions/upload-artifact@v2
With the provided path, there will be 1 file(s) uploaded
Error: Provided rootDirectory /home/runner/work/slug/slug/bazel-bin is not a valid directory

Bazel provides bazel info bazel-bin to get the real path, however it looks like command substitution isn't supported within path.

@SCOTT-HAMILTON
Copy link

SCOTT-HAMILTON commented Apr 27, 2021

I can reproduce this same exact issue with a nix result folder symlink.

    - name: "Upload artifact to github"
      uses: actions/upload-artifact@v2
      with:
        name: Test-driver screenshots
        path: result/screen*
With the provided path, there will be 9 files uploaded
Error: Provided rootDirectory /home/runner/work/tabbed/tabbed/result is not a valid directory

By the way, the result* fix didn't work for me. It does remove the error but the files don't get uploaded.

@RachelXGanon
Copy link

Is this bug fixed?
I'm using a symbolic link in windows, with this action and get
Error: Provided rootDirectory<path> is not a valid directory

@zhangguanzhang
Copy link

zhangguanzhang commented Jan 18, 2022

Is this bug fixed?
I'm using a symbolic link in actions, with this action and get

Error: Provided rootDirectory /home/runner/work/Actions-OpenWrt/Actions-OpenWrt/openwrt is not a valid directory

@finolacahill
Copy link

+1 on this issue. Failing out for a symlinked directory

@n8henrie
Copy link

n8henrie commented Feb 24, 2022

Running into this error (Error: Provided rootDirectory /tmp is not a valid directory) on a macos builder, trying to upload /tmp/qs_build_settings.

https://github.com/quicksilver/Quicksilver/runs/5321405744?check_suite_focus=true

Run actions/upload-artifact@v2
  with:
    name: BUILD_SETTINGS
    path: /tmp/qs_build_settings
    if-no-files-found: warn
  env:
    QS_BUILD_ONLY: 1
With the provided path, there will be 1 file uploaded
Starting artifact upload
For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging
Artifact name is valid!
Error: Provided rootDirectory /tmp is not a valid directory

Trying to debug:

+ ls -l /tmp/qs_build_settings
-rw-r--r--  1 runner  wheel  27668 Feb 24 16:02 /tmp/qs_build_settings
+ ls -ldh /tmp
lrwxr-xr-x@ 1 root  wheel    11B Jan  1  2020 /tmp -> private/tmp

EDIT: Changing path from /tmp/qs_build_settings to /private/tmp/qs_build_settings seems to work.

@exFalso
Copy link

exFalso commented Mar 28, 2022

Note, workaround is to dereference the symlink with readlink and pass it through with $GITHUB_ENV:

      - run: nix-build XXX # produces `result` symlink
      - run: echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV
      - uses: actions/upload-artifact@v2
        with:
          name: XXX
          path: ${{ env.UPLOAD_PATH }}

kateinoigakukun added a commit to kateinoigakukun/llvm-next-function-merging that referenced this issue Aug 7, 2022
kateinoigakukun added a commit to kateinoigakukun/llvm-next-function-merging that referenced this issue Aug 12, 2022
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 23, 2022
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 23, 2022
Use GitHub-provided temp folder to work around actions/upload-artifact#92
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 23, 2022
Use GitHub-provided temp folder to work around actions/upload-artifact#92
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 23, 2022
Use GitHub-provided temp folder to work around actions/upload-artifact#92
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 23, 2022
Use GitHub-provided temp folder to work around actions/upload-artifact#92
MattiSG added a commit to OpenTermsArchive/engine that referenced this issue Aug 24, 2022
Use GitHub-provided temp folder to work around actions/upload-artifact#92
n8henrie added a commit to n8henrie/nixos-btrfs-pi that referenced this issue Aug 25, 2022
@konradpabjan
Copy link
Collaborator

actions/toolkit#1190 has been merged in but a new version of @actions/artifact needs to be published and the changes pulled into upload-artifact with the next release

@jdcole
Copy link

jdcole commented Feb 4, 2023

For anybody searching for an answer, this is huge problem for bazel builds due all the symlinking in build-* directories. Looking forward to it hitting upload-artifact!

nickbreen added a commit to nickbreen/bz-platforms2 that referenced this issue Jul 4, 2023
nickbreen added a commit to nickbreen/bz-platforms2 that referenced this issue Jul 4, 2023
nickbreen added a commit to nickbreen/bes that referenced this issue Feb 7, 2024
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

Successfully merging a pull request may close this issue.