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

feat: add support for unzip argument in downloadArtifact

Open shiipou opened this issue 6 months ago • 1 comments

This PR just add the possibility to filter what we want to unzip or not when downloading artifacts.

This feature was asked by so many people, and the implementation change almost nothing in the code. So it won't break any part of the action.

Here a simple example that show how it work : https://github.com/shiipou/download-artifact/blob/main/.github/workflows/test.yml

You can also try it with this workflow :

Workflow
name: Loop Over Artifact IDs

on: [push]

permissions:
  contents: write
  actions: write
  packages: write

jobs:
  create-artifacts:
    runs-on: ubuntu-latest
    steps:
      - name: Create and upload artifacts
        run: |
          mkdir -p artifact1 artifact2
          echo "Content1" > artifact1/file.txt
          echo "Content2.1" > artifact2/file1.txt
          echo "Content2.2" > artifact2/file2.txt
          echo "Content2.3" > artifact2/file3.txt
      - id: artifact-1
        name: Upload artifact 1
        uses: actions/upload-artifact@v4
        with:
          name: artifact1
          path: artifact1/*
      - id: artifact-2
        name: Upload artifact 2
        uses: actions/upload-artifact@v4
        with:
          name: artifact2
          path: artifact2/*
    outputs:
      artifact-1-id: ${{ steps.artifact-1.outputs.artifact-id }}
      artifact-2-id: ${{ steps.artifact-2.outputs.artifact-id }}

  process-artifacts:
    needs: create-artifacts
    runs-on: ubuntu-latest
    steps:
      - id: download-artifacts
        name: Download artifacts
        uses: shiipou/download-artifact@main
        with:
          artifact-ids: ${{ needs.create-artifacts.outputs.artifact-1-id }},${{ needs.create-artifacts.outputs.artifact-2-id }}
          path: artifacts/
          unzip: ${{ needs.create-artifacts.outputs.artifact-1-id }}
      - name: print artifacts
        run: ls -pAR artifacts/
      - name: unzip artifacts
        run: unzip artifacts/**/*.zip

image

This PR need this (https://github.com/actions/toolkit/pull/2095) to be merged before.

This simply add a new unzip input, this input take as value : artefact-ids, artefact-names, true, false, or '*'.

  • artefact-ids will be a comma separated string of artifact's ids we want to unzip
  • artefact-names will be a comma separated string of artefact's names we want to unzip
  • true is used to unzip everything
  • false is used to keep everything zipped
  • * is used to unzip everything

shiipou avatar Jun 19 '25 17:06 shiipou

I've rebased the PR on the latest commit of main.

shiipou avatar Dec 03 '25 13:12 shiipou