Skip to content

feat: add support for unzip argument in downloadArtifact - #409

Open
shiipou wants to merge 1 commit into
actions:mainfrom
shiipou:main
Open

feat: add support for unzip argument in downloadArtifact#409
shiipou wants to merge 1 commit into
actions:mainfrom
shiipou:main

Conversation

@shiipou

@shiipou shiipou commented Jun 19, 2025

Copy link
Copy Markdown

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 (actions/toolkit#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
shiipou requested a review from a team as a code owner June 19, 2025 17:41
Copilot AI review requested due to automatic review settings December 3, 2025 13:10
@shiipou

shiipou commented Dec 3, 2025

Copy link
Copy Markdown
Author

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for selective artifact unzipping when downloading artifacts, addressing a frequently requested feature. The implementation introduces a new unzip input parameter that allows users to control whether downloaded artifacts should be automatically extracted or kept in their zipped format. This is accomplished by passing the unzip flag to the underlying downloadArtifact method from @actions/toolkit.

Key changes:

  • Added new unzip input parameter that accepts true, false, *, or comma-separated artifact IDs/names
  • Modified download logic to determine per-artifact whether to unzip based on the input value
  • Added integration tests in the workflow to verify zipped artifact downloads

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 8 comments.

File Description
action.yml Adds the unzip input definition with default value '*' to unzip all artifacts by default
src/constants.ts Adds UnZip enum value to the Inputs enum for the new parameter
src/download-artifact.ts Implements the unzip logic by parsing the input and passing the appropriate flag to each artifact download
.github/workflows/test.yml Adds integration tests for downloading artifacts in zipped format using both pattern matching and artifact IDs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread action.yml
description: 'IDs of the artifacts to download, comma-separated. Either inputs `artifact-ids` or `name` can be used, but not both.'
required: false
unzip:
description: 'Whenever to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description uses "Whenever" but should use "Whether". "Whenever" means "every time that" while "Whether" means "if" which is the intended meaning here.

Suggested change
description: 'Whenever to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'
description: 'Whether to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'
Copilot uses AI. Check for mistakes.
Comment thread src/constants.ts
MergeMultiple = 'merge-multiple',
ArtifactIds = 'artifact-ids'
ArtifactIds = 'artifact-ids',
UnZip = "unzip"

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum value UnZip uses inconsistent casing compared to other enum values. It should be Unzip to match the PascalCase convention used by other values like ArtifactIds, MergeMultiple, etc.

Suggested change
UnZip = "unzip"
Unzip = "unzip"
Copilot uses AI. Check for mistakes.
Comment thread src/download-artifact.ts
expectedHash: artifact.digest
})
}))
const unzip_list = inputs.unzip.split(',');

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comma-separated value parsing doesn't follow the same pattern used elsewhere in this file (lines 93-96). When inputs.unzip is empty, .split(',') returns [''] which could cause unexpected matches. Follow the existing pattern: const unzipList = inputs.unzip.split(',').map(s => s.trim()).filter(s => s !== ''); This ensures empty values are filtered out and whitespace is trimmed, consistent with how artifactIds is parsed.

Suggested change
const unzip_list = inputs.unzip.split(',');
const unzip_list = inputs.unzip.split(',').map(s => s.trim()).filter(s => s !== '');
Copilot uses AI. Check for mistakes.
Comment thread src/download-artifact.ts Outdated
Comment on lines +173 to +175
const unzip_list = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable unzip_list uses snake_case, but the codebase convention is camelCase for local variables (e.g., artifactIdList on line 93, resolvedPath on line 50, isSingleArtifactDownload on line 48). It should be unzipList to maintain consistency.

Suggested change
const unzip_list = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);
const unzipList = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzipList.includes(artifact.id.toString()) || unzipList.includes(artifact.name);
Copilot uses AI. Check for mistakes.
Comment thread src/download-artifact.ts Outdated
Comment on lines +173 to +175
const unzip_list = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unzip input functionality lacks unit test coverage. The existing test file __tests__/download.test.ts has comprehensive tests for other inputs (name, artifact-ids, pattern, etc.), but there are no tests verifying the unzip logic. Consider adding tests for:

  • unzip: 'true' - should unzip all artifacts
  • unzip: 'false' - should not unzip any artifacts
  • unzip: '*' - should unzip all artifacts
  • unzip: '<artifact-id>' - should only unzip the specified artifact by ID
  • unzip: '<artifact-name>' - should only unzip the specified artifact by name
  • unzip: '<id1>,<id2>' - should unzip multiple artifacts by ID
Copilot uses AI. Check for mistakes.
Comment thread action.yml
description: 'IDs of the artifacts to download, comma-separated. Either inputs `artifact-ids` or `name` can be used, but not both.'
required: false
unzip:
description: 'Whenever to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description could be clearer about the format of this input. Consider rewording to: "Whether to unzip the artifact after downloading. Accepts: 'true' or '' to unzip all artifacts, 'false' to keep all zipped, or a comma-separated list of artifact IDs or names to selectively unzip. Defaults to ''."

Suggested change
description: 'Whenever to unzip the artifact after downloading. Comma separated list of artifact-ids, artifact-name or "*". Defaults to "*".'
description: "Whether to unzip the artifact after downloading. Accepts: 'true' or '*' to unzip all artifacts, 'false' to keep all zipped, or a comma-separated list of artifact IDs or names to selectively unzip. Defaults to '*'."
Copilot uses AI. Check for mistakes.
Comment thread src/download-artifact.ts Outdated
Comment on lines +173 to +175
const unzip_list = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable reference unzip_list should be unzipList to match the camelCase naming convention used throughout the codebase.

Suggested change
const unzip_list = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzip_list.includes(artifact.id.toString()) || unzip_list.includes(artifact.name);
const unzipList = inputs.unzip.split(',');
const downloadPromises = artifacts.map(artifact => {
const unzip = inputs.unzip === 'true' || inputs.unzip === '*' || unzipList.includes(artifact.id.toString()) || unzipList.includes(artifact.name);
Copilot uses AI. Check for mistakes.
Comment thread src/constants.ts
MergeMultiple = 'merge-multiple',
ArtifactIds = 'artifact-ids'
ArtifactIds = 'artifact-ids',
UnZip = "unzip"

Copilot AI Dec 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string value uses double quotes ("unzip"), but all other enum values in this file use single quotes (e.g., 'name', 'path', 'artifact-ids'). This should be changed to 'unzip' for consistency with the codebase's quote style.

Suggested change
UnZip = "unzip"
UnZip = 'unzip'
Copilot uses AI. Check for mistakes.
@iTrooz

iTrooz commented Jan 9, 2026

Copy link
Copy Markdown

Similar feature in the CLI: cli/cli#12435

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants