mirror of
https://code.forgejo.org/actions/upload-artifact.git
synced 2025-05-19 15:44:46 +00:00
Exclude hidden files by default backport
This commit is contained in:
parent
a8a3f3ad30
commit
afc7e4a27d
8 changed files with 178 additions and 69 deletions
|
@ -3,7 +3,8 @@ export enum Inputs {
|
|||
Name = 'name',
|
||||
Path = 'path',
|
||||
IfNoFilesFound = 'if-no-files-found',
|
||||
RetentionDays = 'retention-days'
|
||||
RetentionDays = 'retention-days',
|
||||
IncludeHiddenFiles = 'include-hidden-files'
|
||||
}
|
||||
|
||||
export enum NoFileOptions {
|
||||
|
|
|
@ -11,6 +11,7 @@ export function getInputs(): UploadInputs {
|
|||
|
||||
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
||||
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
||||
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||
|
||||
if (!noFileBehavior) {
|
||||
core.setFailed(
|
||||
|
@ -25,7 +26,8 @@ export function getInputs(): UploadInputs {
|
|||
const inputs = {
|
||||
artifactName: name,
|
||||
searchPath: path,
|
||||
ifNoFilesFound: noFileBehavior
|
||||
ifNoFilesFound: noFileBehavior,
|
||||
includeHiddenFiles
|
||||
} as UploadInputs
|
||||
|
||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -20,4 +20,9 @@ export interface UploadInputs {
|
|||
* Duration after which artifact will expire in days
|
||||
*/
|
||||
retentionDays: number
|
||||
|
||||
/**
|
||||
* Whether or not to include hidden files in the artifact
|
||||
*/
|
||||
includeHiddenFiles: boolean
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue