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

[docs] Uploading different files to the same artifact from multiple jobs

Open PathogenDavid opened this issue 2 years ago • 4 comments

What files would you like to change?

https://github.com/actions/upload-artifact/blob/f4ac36d2052d09212226799b513ca60c91a09bfc/README.md?plain=1#L131-L177

What are your suggested changes?

In the "Uploading to the same artifact" section, it is warned that uploading to the same artifact from multiple jobs can have unexpected results. The proposed workaround is to upload a different artifact from each job in the matrix.

While this does work, it's not super convenient if you need to be able to download all artifacts from a matrixed job in one go.


Based on my understanding of how artifacts in GitHub Actions work, it seems to me like it should be possible to upload to the same artifact from multiple jobs as long as the file paths are all different. For example:

    strategy:
      matrix:
          node-version: [8.x, 10.x, 12.x, 13.x]
    steps:
        - name: Create a file
          # Note the change below ______________________vvvvvvvvvvvvvvvvvvvvvvvvvvv
          run: echo ${{ matrix.node-version }} > my_file_${{ matrix.node-version }}.txt
        - name: Accidentally upload to the same artifact via multiple jobs
          uses: actions/upload-artifact@v2
          with:
              name: my-artifact
              path: ${{ github.workspace }}

In practice this seems to work fine, but it would be nice to have it clarified in the documentation whether A) this is an intended/supported feature or B) if it's actually still problematic and I'm relying on a race condition succeeding.

If someone from GitHub who knows how the backend works can clarify whether this works intentionally, I can submit a PR adding the appropriate example/disclaimer.

PathogenDavid avatar Dec 07 '21 15:12 PathogenDavid