2023-08-04 09:53:42 -04:00
|
|
|
import * as core from '@actions/core'
|
2023-08-03 13:34:41 -04:00
|
|
|
import {UploadOptions} from './upload-options'
|
|
|
|
|
import {UploadResponse} from './upload-response'
|
2023-08-04 09:53:42 -04:00
|
|
|
import {validateArtifactName} from './path-and-artifact-name-validation'
|
|
|
|
|
import {
|
|
|
|
|
UploadZipSpecification,
|
|
|
|
|
getUploadZipSpecification,
|
|
|
|
|
validateRootDirectory
|
|
|
|
|
} from './upload-zip-specification'
|
2023-08-03 13:34:41 -04:00
|
|
|
|
|
|
|
|
export async function uploadArtifact(
|
|
|
|
|
name: string,
|
2023-08-04 09:53:42 -04:00
|
|
|
files: string[],
|
|
|
|
|
rootDirectory: string,
|
2023-08-03 13:34:41 -04:00
|
|
|
options?: UploadOptions | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
|
|
|
): Promise<UploadResponse> {
|
2023-08-04 09:53:42 -04:00
|
|
|
validateArtifactName(name)
|
|
|
|
|
validateRootDirectory(rootDirectory)
|
|
|
|
|
|
|
|
|
|
const zipSpecification: UploadZipSpecification[] = getUploadZipSpecification(
|
|
|
|
|
files,
|
|
|
|
|
rootDirectory
|
|
|
|
|
)
|
|
|
|
|
if (zipSpecification.length === 0) {
|
|
|
|
|
core.warning(`No files were found to upload`)
|
|
|
|
|
return {
|
|
|
|
|
success: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-03 13:34:41 -04:00
|
|
|
// TODO - Implement upload functionality
|
|
|
|
|
|
|
|
|
|
const uploadResponse: UploadResponse = {
|
2023-08-04 09:53:42 -04:00
|
|
|
success: true,
|
|
|
|
|
size: 0,
|
|
|
|
|
id: 0
|
2023-08-03 13:34:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return uploadResponse
|
|
|
|
|
}
|