mirror of
https://gitea.com/actions/upload-artifact.git
synced 2026-03-02 14:29:36 +08:00
Support direct file uploads
This commit is contained in:
@@ -6,7 +6,8 @@ export enum Inputs {
|
||||
RetentionDays = 'retention-days',
|
||||
CompressionLevel = 'compression-level',
|
||||
Overwrite = 'overwrite',
|
||||
IncludeHiddenFiles = 'include-hidden-files'
|
||||
IncludeHiddenFiles = 'include-hidden-files',
|
||||
Archive = 'archive'
|
||||
}
|
||||
|
||||
export enum NoFileOptions {
|
||||
|
||||
@@ -10,6 +10,7 @@ export function getInputs(): UploadInputs {
|
||||
const path = core.getInput(Inputs.Path, {required: true})
|
||||
const overwrite = core.getBooleanInput(Inputs.Overwrite)
|
||||
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||
const archive = core.getBooleanInput(Inputs.Archive)
|
||||
|
||||
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
||||
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
||||
@@ -29,7 +30,8 @@ export function getInputs(): UploadInputs {
|
||||
searchPath: path,
|
||||
ifNoFilesFound: noFileBehavior,
|
||||
overwrite: overwrite,
|
||||
includeHiddenFiles: includeHiddenFiles
|
||||
includeHiddenFiles: includeHiddenFiles,
|
||||
archive: archive
|
||||
} as UploadInputs
|
||||
|
||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||
|
||||
@@ -57,6 +57,14 @@ export async function run(): Promise<void> {
|
||||
)
|
||||
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
||||
|
||||
// Validate that only a single file is uploaded when archive is false
|
||||
if (!inputs.archive && searchResult.filesToUpload.length > 1) {
|
||||
core.setFailed(
|
||||
`When 'archive' is set to false, only a single file can be uploaded. Found ${searchResult.filesToUpload.length} files to upload.`
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (inputs.overwrite) {
|
||||
await deleteArtifactIfExists(inputs.artifactName)
|
||||
}
|
||||
@@ -70,6 +78,10 @@ export async function run(): Promise<void> {
|
||||
options.compressionLevel = inputs.compressionLevel
|
||||
}
|
||||
|
||||
if (!inputs.archive) {
|
||||
options.skipArchive = true
|
||||
}
|
||||
|
||||
await uploadArtifact(
|
||||
inputs.artifactName,
|
||||
searchResult.filesToUpload,
|
||||
|
||||
@@ -35,4 +35,10 @@ export interface UploadInputs {
|
||||
* Whether or not to include hidden files in the artifact
|
||||
*/
|
||||
includeHiddenFiles: boolean
|
||||
|
||||
/**
|
||||
* Whether or not to archive (zip) the artifact before uploading.
|
||||
* When false, only a single file can be uploaded.
|
||||
*/
|
||||
archive: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user