upload-artifact icon indicating copy to clipboard operation
upload-artifact copied to clipboard

Unable to upload a folder as an artifact

Open gxferreira opened this issue 4 years ago • 5 comments

It seems impossible to upload a specific folder as an artifact. In my case, I'd like to simply upload the directory dist instead of its content. My code is similar to this example.

      - name: Uploading dist
        uses: actions/upload-artifact@v2
        with:
          name: artefact
          path: ./dist

I tried another variations using wildcards but I didn't succeed uploading the dist within my artifact. Isn't possible with this action?

gxferreira avatar Sep 16 '21 16:09 gxferreira

My config looking like this has worked

      - uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: cypress-artifacts
          path: |
            cypress/screenshots/
            cypress/videos/

I think there also has to be things in the folder or it'll skip it

Powersource avatar Sep 23 '21 13:09 Powersource

Is this still a thing? I believe the problem here is that this action won't upload files that are .gitignored. At least that seems to be what I'm seeing.

andrewsw avatar May 16 '22 23:05 andrewsw

I had a similar problem with my workflow. However the problem in my case was that I thought by setting a default value for the working directory it should be applied in all steps, but it only applies on the run steps.

So for the upload-artifact action I had to include the complete path from the root of the repository, like this:

jobs:
  run-playwright-tests:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./tests/e2e
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "14.x"
      - name: Install dependencies
        run: npm ci
      - name: Install Playwright
        run: npx playwright install --with-deps
      - name: Run Playwright tests
        run: npx playwright test
      - uses: actions/upload-artifact@v3
        if: always()
        with:
          name: playwright-report
          path: |
            tests/e2e/playwright-report/
          retention-days: 15

stefanalfbo avatar May 18 '22 19:05 stefanalfbo

Ah, yeah. That's what I ultimately discovered, as well. The action doesn't respect working-directory.

andrewsw avatar May 18 '22 20:05 andrewsw

Here is a simple workaround, add one more step, just before the upload-artifact step:

      ...
      ...
      - run: mkdir tmp-dir && mv dist tmp-dir/ && mv tmp-dir dist
      - name: Uploading dist
        uses: actions/upload-artifact@v2
        with:
          name: artefact
          path: ./dist
      ...
      ...

micl2e2 avatar Nov 12 '23 09:11 micl2e2