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

Maintain path relative to root folder #174

Open
thenewguy opened this issue Feb 8, 2021 · 7 comments
Open

Maintain path relative to root folder #174

thenewguy opened this issue Feb 8, 2021 · 7 comments

Comments

@thenewguy
Copy link

thenewguy commented Feb 8, 2021

It would be helpful if my artifact would not squash the directory structure. For example,

- name: Archive production artifacts
        uses: actions/upload-artifact@v2
        with:
          name: assets
          retention-days: 5
          path: ./root/relative/path/to/my/file*

I end up with a zipfile containing file.js and file.css. What I want is a zipfile containing root/relative/path/to/my/file.js and root/relative/path/to/my/file.css

-- edit --

The reason for this is so that I can unpack it on my project file for use in the next job

-- edit --

This command produces the behavior I am looking for. I am having to manually pack & unpack it. But this gives you the idea:

zip artifact.zip ./root/relative/path/to/my/file*

This gives me a zip file with root/relative/path/to/my/file.js and root/relative/path/to/my/file.css

@thenewguy thenewguy added the bug Something isn't working label Feb 8, 2021
@rcowsill
Copy link

rcowsill commented Feb 25, 2021

It'd be great to have an option to specify the root path to use for the artifacts. It could be optional, and if not specified the current behaviour would be used.

As a workaround in the meantime you can make an empty file in root/ and include it in the artifact. That should force the action to produce this directory structure:

empty.txt
relative
└ path
  └ to
    └ my
       file.css
       file.js

@konradpabjan
Copy link
Collaborator

This behavior is documented: https://github.com/actions/upload-artifact#upload-using-multiple-paths-and-exclusions

The reason why only file.js and file.css are included without a root directory is because you're using a wildcard pattern and it gets cutoff there.

If you do something like path: ./*/relative/path/to/my/file* then it should include the full path.

@konradpabjan konradpabjan removed the bug Something isn't working label Mar 18, 2021
@aminya
Copy link

aminya commented Jun 2, 2021

There should be an option to maintain the paths. The reason is that if you use download-artifact later, you have to manually move the files from the ./artifact folder to place them in the correct path.

      - name: Upload built files
        uses: actions/upload-artifact@v2
        with:
          path: |
            ./dist
      - name: Download articats
        uses: actions/download-artifact@v2
      - name: Place artifacts
        shell: bash
        run: |
          rm -rf dist
          mv artifact/* ./

@tulsishell
Copy link

I found a way around this - include one other file in your artifact which doesn't have the same base path as all the other files.
It should be in a completely different folder from the root itself.
This way the action doesn't find any least common ancestor of all the search paths and gives you complete directory structure. :)

HumzahJavid added a commit to HumzahJavid/dating_app that referenced this issue Apr 15, 2022
@mgebundy
Copy link

mgebundy commented Jun 7, 2023

Thanks for the workaround @rcowsill & @tulsishell

I would love to see a simple option for maintaining paths, it's causing similar issues on our end and I'm not even interested in using wildcards.

Edit: this workaround also means I can't use if-no-files-found: error at all, since there will ALWAYS be an dummy file included in the upload.

@asos-tomp
Copy link

I found a way around this - include one other file in your artifact which doesn't have the same base path as all the other files. It should be in a completely different folder from the root itself. This way the action doesn't find any least common ancestor of all the search paths and gives you complete directory structure. :)

Frustratingly, an approach that can't be used with parallel jobs I assume, since unless each choses a unique "one other file", the mentioned 503 errors will kick in.

@retorquere
Copy link

Frustratingly, an approach that can't be used with parallel jobs I assume, since unless each choses a unique "one other file", the mentioned 503 errors will kick in.

I'm running this to keep the dir structure

mkdir artifacts
mkdir .artifacts
mktemp .artifacts/artifacts.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and then specify both for upload. Which is... not great, but works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants