Skip to content

[experiment] merge sub-action#503

Closed
robherley wants to merge 10 commits intomainfrom
robherley/merge-artifact
Closed

[experiment] merge sub-action#503
robherley wants to merge 10 commits intomainfrom
robherley/merge-artifact

Conversation

@robherley
Copy link
Copy Markdown
Contributor

@robherley robherley commented Jan 19, 2024

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
Copy link
Copy Markdown
Contributor Author

This was added in release v4.3.0

@robherley robherley closed this Jan 25, 2024
@robherley robherley deleted the robherley/merge-artifact branch October 8, 2024 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant