actions / upload-artifact

MIT License
3.16k stars 710 forks source link

[bug] Only first artifact is found when using `upload-artifact@v3` inside a container #441

Open ababushk opened 1 year ago

ababushk commented 1 year ago

What happened?

When used inside a container and when a few paths provided, upload-artifact@v3 uploads only files found using the first glob provided.

What did you expect to happen?

All files are found using all the globs provided via multi-line string.

How can we reproduce it?

I've created minimal workflow file to reproduce the issue:

name: Upload artifacts issue demo
on:
  workflow_dispatch:
jobs:
  works-outside-container:
    name: Works outside container
    runs-on: ubuntu-20.04
    env:
      TEST_REPORTS_DIR: ${{ github.workspace }}/path/to/test/reports
    steps:
    - name: Create artifacts
      run: |
        echo "TEST_REPORTS_DIR (YAML expansion): ${{ env.TEST_REPORTS_DIR }}"
        echo "TEST_REPORTS_DIR (shell expansion): ${TEST_REPORTS_DIR}"
        mkdir -p ${TEST_REPORTS_DIR}
        echo "First test report" >> ${TEST_REPORTS_DIR}/first_test_report.txt
        echo "Second test report" >> ${TEST_REPORTS_DIR}/second_test_report.txt

    - name: Upload artifacts # two files will be in the archive produced
      uses: actions/upload-artifact@v3
      with:
        name: outside_container
        path: |
          ${{ env.TEST_REPORTS_DIR }}/first_test_report.txt
          ${{ env.TEST_REPORTS_DIR }}/second_test_report.txt

        if-no-files-found: 'error'

  doesnt-work-in-container:
    name: Doesn't work in container
    runs-on: ubuntu-20.04
    container:
      image: ubuntu:20.04
    env:
      TEST_REPORTS_DIR: ${{ github.workspace }}/path/to/test/reports
    steps:
    - name: Create artifacts
      run: |
        echo "TEST_REPORTS_DIR (YAML expansion): ${{ env.TEST_REPORTS_DIR }}"
        echo "TEST_REPORTS_DIR (shell expansion): ${TEST_REPORTS_DIR}"
        mkdir -p ${TEST_REPORTS_DIR}
        echo "First test report" >> ${TEST_REPORTS_DIR}/first_test_report.txt
        echo "Second test report" >> ${TEST_REPORTS_DIR}/second_test_report.txt

    - name: Upload artifacts # one file will be in the archive produced
      uses: actions/upload-artifact@v3
      with:
        name: inside_container
        path: |
          ${{ env.TEST_REPORTS_DIR }}/first_test_report.txt
          ${{ env.TEST_REPORTS_DIR }}/second_test_report.txt # will be ignored

        if-no-files-found: 'error'

In the first job the archive will contain two text files, in the second - only one. You can check the result here https://github.com/ababushk/githubactionstest/actions/runs/6226598794

Anything else we need to know?

It looks like it is connected to https://github.com/actions/runner/issues/2058

What version of the action are you using?

v3

What are your runner environments?

linux

Are you on GitHub Enterprise Server? If so, what version?

No response

liskin commented 4 months ago

This is much more of an issue now that v3 is deprecated and we're supposed to migrate to upload-artifact@v4, which doesn't automatically merge artifacts and we're meant to supply multiple paths instead.

Also, bloody hell, due to https://github.com/actions/upload-artifact/issues/457 still not being fixed these files are just ignored silently. Brilliant.