upload-artifact
upload-artifact copied to clipboard
Unable to upload a folder as an artifact
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?
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
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.
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
Ah, yeah. That's what I ultimately discovered, as well. The action doesn't respect working-directory.
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
...
...