actions / upload-artifact

MIT License
3.01k stars 683 forks source link

[experiment] merge sub-action #503

Closed robherley closed 5 months ago

robherley commented 5 months ago

Reorganizing and adding sub-action to "merge" artifacts.

For the simplest use-case, it would look something like:

jobs:
  upload:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        foo: [a, b, c]

    steps:
      - name: Run a one-line script
        run: echo "hello from job ${{ matrix.foo }}" > file-${{ matrix.foo }}.txt
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: my-artifact-${{ matrix.foo }}
          path: file-${{ matrix.foo }}.txt
  merge:
    runs-on: ubuntu-latest
    needs: upload
    steps:
      - name: Merge Artifacts
        uses: actions/upload-artifact/merge@v4

Without any inputs, the above would merge the three my-artifact-* actions into merged-artifact. There are of course multiple options to adjust the behavior and refine, e.g.

  merge:
    runs-on: ubuntu-latest
    needs: upload
    steps:
      - name: Merge Artifacts
        uses: actions/upload-artifact/merge@v4
        with:
          # the name of the merged artifact
          into: my-merged-artifact
          # the pattern to match artifacts to merge
          pattern: my-artifact-*
          # whether or not to place the artifacts into separate directories
          separate-directories: false
          # to delete the artifacts after merging
          delete-merged: true
          # retention days, same as the upload action
          retention-days: 90
          # compression level, same as the upload action
          compression-level: 9

This PR does change a lot to the structure of the repo, so I'll probably split it into two to make it easier to review:

  1. Moving the upload logic into it's own directory + unit tests
  2. Adding the merge sub-action, docs + unit tests

Here's an example run: https://github.com/robherley/tmp-merge-artifacts/actions/runs/7586676926

robherley commented 5 months ago

This was added in release v4.3.0