mirror of
https://github.com/actions/upload-artifact.git
synced 2025-08-18 06:35:07 +00:00
This commit implements a new boolean input to the action, `follow-symlinks`. This option configures whether the glob expansion will follow any symlinks it finds when determining the set of of files to be archived into the artifact. The default value of the option, which preserves the existing behaviour, is `true`. When set to true, symbolic links will be be followed and expanded If `false`, symbolic links will be included in the archived artifact verbatim. Users may wish to set this option to false if their artifact contains internally-referencing symlinks which would result in significant bloat (and semantic change!) in the source files when the artifact is created. Resolves: actions#93.
82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import * as core from '@actions/core'
|
|
import {create, UploadOptions} from '@actions/artifact'
|
|
import {findFilesToUpload, getDefaultGlobOptions} from './search'
|
|
import {getInputs} from './input-helper'
|
|
import {NoFileOptions} from './constants'
|
|
|
|
async function run(): Promise<void> {
|
|
try {
|
|
const inputs = getInputs()
|
|
const globOptions = {
|
|
...getDefaultGlobOptions(),
|
|
followSymbolicLinks: inputs.followSymlinks
|
|
}
|
|
const searchResult = await findFilesToUpload(inputs.searchPath, globOptions)
|
|
|
|
if (searchResult.filesToUpload.length === 0) {
|
|
// No files were found, different use cases warrant different types of behavior if nothing is found
|
|
switch (inputs.ifNoFilesFound) {
|
|
case NoFileOptions.warn: {
|
|
core.warning(
|
|
`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`
|
|
)
|
|
break
|
|
}
|
|
case NoFileOptions.error: {
|
|
core.setFailed(
|
|
`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`
|
|
)
|
|
break
|
|
}
|
|
case NoFileOptions.ignore: {
|
|
core.info(
|
|
`No files were found with the provided path: ${inputs.searchPath}. No artifacts will be uploaded.`
|
|
)
|
|
break
|
|
}
|
|
}
|
|
} else {
|
|
const s = searchResult.filesToUpload.length === 1 ? '' : 's'
|
|
core.info(
|
|
`With the provided path, there will be ${searchResult.filesToUpload.length} file${s} uploaded`
|
|
)
|
|
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
|
|
|
if (searchResult.filesToUpload.length > 10000) {
|
|
core.warning(
|
|
`There are over 10,000 files in this artifact, consider create an archive before upload to improve the upload performance.`
|
|
)
|
|
}
|
|
|
|
const artifactClient = create()
|
|
const options: UploadOptions = {
|
|
continueOnError: false
|
|
}
|
|
if (inputs.retentionDays) {
|
|
options.retentionDays = inputs.retentionDays
|
|
}
|
|
|
|
const uploadResponse = await artifactClient.uploadArtifact(
|
|
inputs.artifactName,
|
|
searchResult.filesToUpload,
|
|
searchResult.rootDirectory,
|
|
options
|
|
)
|
|
|
|
if (uploadResponse.failedItems.length > 0) {
|
|
core.setFailed(
|
|
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
|
|
)
|
|
} else {
|
|
core.info(
|
|
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
|
)
|
|
}
|
|
}
|
|
} catch (err) {
|
|
core.setFailed(err.message)
|
|
}
|
|
}
|
|
|
|
run()
|