mirror of
https://github.com/actions/upload-artifact.git
synced 2025-04-05 22:19:38 +00:00
Exclude hidden files by default
This commit is contained in:
@ -5,5 +5,6 @@ export enum Inputs {
|
||||
SeparateDirectories = 'separate-directories',
|
||||
RetentionDays = 'retention-days',
|
||||
CompressionLevel = 'compression-level',
|
||||
DeleteMerged = 'delete-merged'
|
||||
DeleteMerged = 'delete-merged',
|
||||
IncludeHiddenFiles = 'include-hidden-files',
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ export function getInputs(): MergeInputs {
|
||||
const pattern = core.getInput(Inputs.Pattern, {required: true})
|
||||
const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
|
||||
const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
|
||||
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||
|
||||
const inputs = {
|
||||
name,
|
||||
@ -17,7 +18,8 @@ export function getInputs(): MergeInputs {
|
||||
separateDirectories,
|
||||
deleteMerged,
|
||||
retentionDays: 0,
|
||||
compressionLevel: 6
|
||||
compressionLevel: 6,
|
||||
includeHiddenFiles,
|
||||
} as MergeInputs
|
||||
|
||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||
|
@ -62,7 +62,7 @@ export async function run(): Promise<void> {
|
||||
options.compressionLevel = inputs.compressionLevel
|
||||
}
|
||||
|
||||
const searchResult = await findFilesToUpload(tmpDir)
|
||||
const searchResult = await findFilesToUpload(tmpDir, inputs.includeHiddenFiles)
|
||||
|
||||
await uploadArtifact(
|
||||
inputs.name,
|
||||
|
@ -30,4 +30,9 @@ export interface MergeInputs {
|
||||
* If false, the artifacts will be merged into the root of the destination.
|
||||
*/
|
||||
separateDirectories: boolean
|
||||
|
||||
/**
|
||||
* Whether or not to include hidden files in the artifact
|
||||
*/
|
||||
includeHiddenFiles: boolean
|
||||
}
|
||||
|
@ -11,11 +11,12 @@ export interface SearchResult {
|
||||
rootDirectory: string
|
||||
}
|
||||
|
||||
function getDefaultGlobOptions(): glob.GlobOptions {
|
||||
function getDefaultGlobOptions(_includeHiddenFiles: boolean): glob.GlobOptions {
|
||||
return {
|
||||
followSymbolicLinks: true,
|
||||
implicitDescendants: true,
|
||||
omitBrokenSymbolicLinks: true
|
||||
omitBrokenSymbolicLinks: true,
|
||||
// excludeHiddenFiles: !includeHiddenFiles,
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,12 +81,12 @@ function getMultiPathLCA(searchPaths: string[]): string {
|
||||
|
||||
export async function findFilesToUpload(
|
||||
searchPath: string,
|
||||
globOptions?: glob.GlobOptions
|
||||
includeHiddenFiles?: boolean,
|
||||
): Promise<SearchResult> {
|
||||
const searchResults: string[] = []
|
||||
const globber = await glob.create(
|
||||
searchPath,
|
||||
globOptions || getDefaultGlobOptions()
|
||||
getDefaultGlobOptions(includeHiddenFiles || false)
|
||||
)
|
||||
const rawSearchResults: string[] = await globber.glob()
|
||||
|
||||
|
@ -5,7 +5,8 @@ export enum Inputs {
|
||||
IfNoFilesFound = 'if-no-files-found',
|
||||
RetentionDays = 'retention-days',
|
||||
CompressionLevel = 'compression-level',
|
||||
Overwrite = 'overwrite'
|
||||
Overwrite = 'overwrite',
|
||||
IncludeHiddenFiles = 'include-hidden-files',
|
||||
}
|
||||
|
||||
export enum NoFileOptions {
|
||||
|
@ -9,6 +9,7 @@ export function getInputs(): UploadInputs {
|
||||
const name = core.getInput(Inputs.Name)
|
||||
const path = core.getInput(Inputs.Path, {required: true})
|
||||
const overwrite = core.getBooleanInput(Inputs.Overwrite)
|
||||
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||
|
||||
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
||||
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
||||
@ -27,7 +28,8 @@ export function getInputs(): UploadInputs {
|
||||
artifactName: name,
|
||||
searchPath: path,
|
||||
ifNoFilesFound: noFileBehavior,
|
||||
overwrite: overwrite
|
||||
overwrite: overwrite,
|
||||
includeHiddenFiles: includeHiddenFiles,
|
||||
} as UploadInputs
|
||||
|
||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||
|
@ -24,7 +24,7 @@ async function deleteArtifactIfExists(artifactName: string): Promise<void> {
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
const inputs = getInputs()
|
||||
const searchResult = await findFilesToUpload(inputs.searchPath)
|
||||
const searchResult = await findFilesToUpload(inputs.searchPath, inputs.includeHiddenFiles)
|
||||
if (searchResult.filesToUpload.length === 0) {
|
||||
// No files were found, different use cases warrant different types of behavior if nothing is found
|
||||
switch (inputs.ifNoFilesFound) {
|
||||
|
@ -30,4 +30,9 @@ export interface UploadInputs {
|
||||
* Whether or not to replace an existing artifact with the same name
|
||||
*/
|
||||
overwrite: boolean
|
||||
|
||||
/**
|
||||
* Whether or not to include hidden files in the artifact
|
||||
*/
|
||||
includeHiddenFiles: boolean
|
||||
}
|
||||
|
Reference in New Issue
Block a user