Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a179cdb8d | ||
|
|
eba2a242da | ||
|
|
500e175644 | ||
|
|
83b889d09d | ||
|
|
eeb333dcd2 | ||
|
|
fa39c94ed2 | ||
|
|
59ef34ab24 | ||
|
|
20bcd3b8cb | ||
|
|
aa5cae10db | ||
|
|
f87a4089c5 | ||
|
|
50ad273a1a | ||
|
|
0ff37d0dc6 | ||
|
|
0597a567d0 | ||
|
|
0f573694ad | ||
|
|
99700c1456 |
+20
-2
@@ -1,7 +1,7 @@
|
|||||||
name: 'Upload a Build Artifact'
|
name: 'Upload a Build Artifact'
|
||||||
description: 'Upload a build artifact that can be used by subsequent workflow steps'
|
description: 'Upload a build artifact that can be used by subsequent workflow steps'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
name:
|
name:
|
||||||
description: 'Artifact name'
|
description: 'Artifact name'
|
||||||
default: 'artifact'
|
default: 'artifact'
|
||||||
@@ -23,6 +23,24 @@ inputs:
|
|||||||
|
|
||||||
Minimum 1 day.
|
Minimum 1 day.
|
||||||
Maximum 90 days unless changed from the repository settings page.
|
Maximum 90 days unless changed from the repository settings page.
|
||||||
|
compression-level:
|
||||||
|
description: >
|
||||||
|
The level of compression for Zlib to be applied to the artifact archive.
|
||||||
|
The value can range from 0 to 9:
|
||||||
|
- 0: No compression
|
||||||
|
- 1: Best speed
|
||||||
|
- 6: Default compression (same as GNU Gzip)
|
||||||
|
- 9: Best compression
|
||||||
|
Higher levels will result in better compression, but will take longer to complete.
|
||||||
|
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
|
||||||
|
default: '6'
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
artifact-id:
|
||||||
|
description: >
|
||||||
|
A unique identifier for the artifact that was just uploaded. Empty if artifact upload failed.
|
||||||
|
|
||||||
|
This ID can be used as input to other APIs to download, delete or get more information about an artifact: https://docs.github.com/en/rest/actions/artifacts
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
Vendored
+116712
-5492
File diff suppressed because one or more lines are too long
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"release": "ncc build src/upload-artifact.ts && git add -f dist/",
|
"release": "ncc build src/upload-artifact.ts && git add -f dist/index.js",
|
||||||
"check-all": "concurrently \"npm:format-check\" \"npm:lint\" \"npm:test\" \"npm:build\"",
|
"check-all": "concurrently \"npm:format-check\" \"npm:lint\" \"npm:test\" \"npm:build\"",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/upload-artifact#readme",
|
"homepage": "https://github.com/actions/upload-artifact#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.1.1",
|
"@actions/artifact": "^2.0.0",
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/glob": "^0.3.0",
|
"@actions/glob": "^0.3.0",
|
||||||
"@actions/io": "^1.1.2"
|
"@actions/io": "^1.1.2"
|
||||||
|
|||||||
+2
-1
@@ -3,7 +3,8 @@ export enum Inputs {
|
|||||||
Name = 'name',
|
Name = 'name',
|
||||||
Path = 'path',
|
Path = 'path',
|
||||||
IfNoFilesFound = 'if-no-files-found',
|
IfNoFilesFound = 'if-no-files-found',
|
||||||
RetentionDays = 'retention-days'
|
RetentionDays = 'retention-days',
|
||||||
|
CompressionLevel = 'compression-level'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NoFileOptions {
|
export enum NoFileOptions {
|
||||||
|
|||||||
@@ -36,5 +36,17 @@ export function getInputs(): UploadInputs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const compressionLevelStr = core.getInput(Inputs.CompressionLevel)
|
||||||
|
if (compressionLevelStr) {
|
||||||
|
inputs.compressionLevel = parseInt(compressionLevelStr)
|
||||||
|
if (isNaN(inputs.compressionLevel)) {
|
||||||
|
core.setFailed('Invalid compression-level')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputs.compressionLevel < 0 || inputs.compressionLevel > 9) {
|
||||||
|
core.setFailed('Invalid compression-level. Valid values are 0-9')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-22
@@ -1,5 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '../node_modules/@actions/core/'
|
||||||
import {create, UploadOptions} from '@actions/artifact'
|
import artifact, {
|
||||||
|
UploadArtifactOptions
|
||||||
|
} from '../node_modules/@actions/artifact/lib/artifact'
|
||||||
import {findFilesToUpload} from './search'
|
import {findFilesToUpload} from './search'
|
||||||
import {getInputs} from './input-helper'
|
import {getInputs} from './input-helper'
|
||||||
import {NoFileOptions} from './constants'
|
import {NoFileOptions} from './constants'
|
||||||
@@ -37,36 +39,26 @@ async function run(): Promise<void> {
|
|||||||
)
|
)
|
||||||
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
core.debug(`Root artifact directory is ${searchResult.rootDirectory}`)
|
||||||
|
|
||||||
if (searchResult.filesToUpload.length > 10000) {
|
const options: UploadArtifactOptions = {}
|
||||||
core.warning(
|
|
||||||
`There are over 10,000 files in this artifact, consider creating an archive before upload to improve the upload performance.`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const artifactClient = create()
|
|
||||||
const options: UploadOptions = {
|
|
||||||
continueOnError: false
|
|
||||||
}
|
|
||||||
if (inputs.retentionDays) {
|
if (inputs.retentionDays) {
|
||||||
options.retentionDays = inputs.retentionDays
|
options.retentionDays = inputs.retentionDays
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadResponse = await artifactClient.uploadArtifact(
|
if (typeof inputs.compressionLevel !== 'undefined') {
|
||||||
|
options.compressionLevel = inputs.compressionLevel
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadResponse = await artifact.uploadArtifact(
|
||||||
inputs.artifactName,
|
inputs.artifactName,
|
||||||
searchResult.filesToUpload,
|
searchResult.filesToUpload,
|
||||||
searchResult.rootDirectory,
|
searchResult.rootDirectory,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
|
|
||||||
if (uploadResponse.failedItems.length > 0) {
|
core.info(
|
||||||
core.setFailed(
|
`Artifact ${inputs.artifactName} has been successfully uploaded! Final size is ${uploadResponse.size} bytes. Artifact ID is ${uploadResponse.id}`
|
||||||
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
|
)
|
||||||
)
|
core.setOutput('artifact-id', uploadResponse.id)
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed((error as Error).message)
|
core.setFailed((error as Error).message)
|
||||||
|
|||||||
@@ -20,4 +20,9 @@ export interface UploadInputs {
|
|||||||
* Duration after which artifact will expire in days
|
* Duration after which artifact will expire in days
|
||||||
*/
|
*/
|
||||||
retentionDays: number
|
retentionDays: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The level of compression for Zlib to be applied to the artifact archive.
|
||||||
|
*/
|
||||||
|
compressionLevel?: number
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user