Skip to content

Save-GitHubArtifact

SYNOPSIS

Downloads a GitHub Actions artifact.

SYNTAX

Save-GitHubArtifact [-Owner] <String> [-Repository] <String> [-ID] <String> [[-Path] <String>] [-Expand]
 [-Force] [-PassThru] [[-Context] <Object>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Downloads an artifact from a repository. The artifact is downloaded as a ZIP file to the specified path or the current directory by default. Users must have read access to the repository. For private repositories, personal access tokens (classic) or OAuth tokens with the repo scope are required.

EXAMPLES

EXAMPLE 1

Save-GitHubArtifact -Owner 'octocat' -Repository 'Hello-World' -ID '123456' -Path 'C:\Artifacts'

Output:

Directory: C:\Artifacts

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        03/31/2025     12:00                artifact-123456.zip

Downloads artifact ID '123456' from the 'Hello-World' repository owned by 'octocat' to the specified path.

EXAMPLE 2

Save-GitHubArtifact -Owner 'octocat' -Repository 'Hello-World' -Name 'module' -Path 'C:\Artifacts\module' -Expand -Force

Output:

Directory: C:\Artifacts

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        03/31/2025     12:00                artifact-123456.zip

Downloads artifact ID 123456 from the 'Hello-World' repository owned by 'octocat' to the specified path, overwriting existing files during download and extraction.

PARAMETERS

-Owner

The account owner of the repository. The name is not case sensitive.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Repository

The name of the repository without the .git extension. The name is not case sensitive.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-ID

The unique identifier of the artifact.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False

-Path

Path to the file or folder for the download. Accepts relative or absolute paths.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: $PWD.Path
Accept pipeline input: False
Accept wildcard characters: False

-Expand

When specified, the ZIP file is extracted to the same directory it was downloaded to.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: Extract

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Force

When specified, overwrites existing files during download and extraction.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

When specified, the ZIP file or the folder where the ZIP file was extracted to is returned.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Context

The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: 5
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

GitHubArtifact

OUTPUTS

System.IO.FileSystemInfo[]

NOTES

Contains the extracted file or folder information from the downloaded artifact. This output can include directories or files depending on the artifact content.

https://psmodule.io/GitHub/Functions/Artifacts/Save-GitHubArtifact/

[Get an artifact](https://docs.github.com/rest/actions/artifacts#get-an-artifact)