1
0
Fork 0
toolkit/packages/artifact
Konrad Pabjan a3d4efa112 Variable renaming 2023-08-01 12:21:08 -04:00
..
__tests__ Preparation for v4 2023-08-01 10:02:46 -04:00
docs Preparation for v4 2023-08-01 10:02:46 -04:00
generated add twirp ts definitions to artifacts 2023-08-01 07:36:49 -07:00
src Variable renaming 2023-08-01 12:21:08 -04:00
CONTRIBUTIONS.md zeit renamed to vercel 2020-08-21 07:32:09 -04:00
LICENSE.md Add License.md to all npm packages (#548) 2020-08-25 16:26:50 -04:00
README.md Cleanup 2023-08-01 12:02:30 -04:00
RELEASES.md Release notes for 1.1.1 2023-01-03 15:19:16 +01:00
package-lock.json Cleanup 2023-08-01 12:02:30 -04:00
package.json Refactoring 2023-08-01 12:15:33 -04:00
tsconfig.json @actions/artifact package (#304) 2020-02-11 09:49:46 -05:00

README.md

@actions/artifact

Usage

You can use this package to interact with the actions artifacts.

Relative paths and absolute paths are both allowed. Relative paths are rooted against the current working directory.

Upload an Artifact

Method Name: uploadArtifact

Inputs

  • name
    • The name of the artifact that is being uploaded
    • Required
  • files
    • A list of file paths that describe what should be uploaded as part of the artifact
    • If a path is provided that does not exist, an error will be thrown
    • Can be absolute or relative. Internally everything is normalized and resolved
    • Required
  • rootDirectory
    • A file path that denotes the root directory of the files being uploaded. This path is used to strip the paths provided in files to control how they are uploaded and structured
    • If a file specified in files is not in the rootDirectory, an error will be thrown
    • Required
  • options
    • Extra options that allow for the customization of the upload behavior
    • Optional

Available Options

  • retentionDays
    • Duration after which artifact will expire in days
    • Minimum value: 1
    • Maximum value: 90 unless changed by repository setting
    • If this is set to a greater value than the retention settings allowed, the retention on artifacts will be reduced to match the max value allowed on the server, and the upload process will continue. An input of 0 assumes default retention value.

Example using Absolute File Paths

const artifact = require('@actions/artifact');
const artifactClient = artifact.create()
const artifactName = 'my-artifact';
const files = [
    '/home/user/files/plz-upload/file1.txt',
    '/home/user/files/plz-upload/file2.txt',
    '/home/user/files/plz-upload/dir/file3.txt'
]
const rootDirectory = '/home/user/files/plz-upload'
const options = {
    continueOnError: true
}

const uploadResult = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options)

Example using Relative File Paths

// Assuming the current working directory is /home/user/files/plz-upload
const artifact = require('@actions/artifact');
const artifactClient = artifact.create()
const artifactName = 'my-artifact';
const files = [
    'file1.txt',
    'file2.txt',
    'dir/file3.txt'
]

const rootDirectory = '.' // Also possible to use __dirname
const options = {
    continueOnError: false
}

const uploadResponse = await artifactClient.uploadArtifact(artifactName, files, rootDirectory, options)

Upload Result

The returned UploadResponse will contain the following information

  • artifactName
    • The name of the artifact that was uploaded
  • size
    • Total size of the artifact that was uploaded in bytes

Contributions

See contributor guidelines for general guidelines and information about toolkit contributions.

For contributions related to this package, see artifact contributions for more information.