mirror of
https://github.com/actions/upload-artifact.git
synced 2025-04-19 06:54:45 +02:00
try to allow to skip archive
This commit is contained in:
parent
589ca5fbdd
commit
bd14001b7a
4 changed files with 7228 additions and 1566 deletions
3188
dist/index.js
vendored
3188
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,7 @@
|
||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
Name = 'name',
|
Name = 'name',
|
||||||
Path = 'path'
|
Path = 'path',
|
||||||
|
SkipArchive = 'skipArchive',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultArtifactName(): string {
|
export function getDefaultArtifactName(): string {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {create, UploadOptions} from '@actions/artifact'
|
import {create, UploadOptions, ArtifactClient} from '@actions/artifact'
|
||||||
import {Inputs, getDefaultArtifactName} from './constants'
|
import {Inputs, getDefaultArtifactName} from './constants'
|
||||||
import {findFilesToUpload} from './search'
|
import {findFilesToUpload} from './search'
|
||||||
|
import { basename } from 'path';
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const name = core.getInput(Inputs.Name, {required: false})
|
const name = core.getInput(Inputs.Name, {required: false})
|
||||||
const path = core.getInput(Inputs.Path, {required: true})
|
const path = core.getInput(Inputs.Path, {required: true})
|
||||||
|
const skipArchive = core.getInput(Inputs.SkipArchive, {required: false})
|
||||||
|
|
||||||
const searchResult = await findFilesToUpload(path)
|
const searchResult = await findFilesToUpload(path)
|
||||||
if (searchResult.filesToUpload.length === 0) {
|
if (searchResult.filesToUpload.length === 0) {
|
||||||
|
@ -23,26 +25,44 @@ async function run(): Promise<void> {
|
||||||
const options: UploadOptions = {
|
const options: UploadOptions = {
|
||||||
continueOnError: false
|
continueOnError: false
|
||||||
}
|
}
|
||||||
const uploadResponse = await artifactClient.uploadArtifact(
|
|
||||||
name || getDefaultArtifactName(),
|
|
||||||
searchResult.filesToUpload,
|
|
||||||
searchResult.rootDirectory,
|
|
||||||
options
|
|
||||||
)
|
|
||||||
|
|
||||||
if (uploadResponse.failedItems.length > 0) {
|
const uploadedArtifacts: string[] = [];
|
||||||
core.setFailed(
|
|
||||||
`An error was encountered when uploading ${uploadResponse.artifactName}. There were ${uploadResponse.failedItems.length} items that failed to upload.`
|
if (skipArchive) {
|
||||||
)
|
for (const file of searchResult.filesToUpload) {
|
||||||
|
const resultName = await uploadArtifacts(artifactClient, [file], searchResult.rootDirectory, options, basename(file));
|
||||||
|
resultName && uploadedArtifacts.push(resultName);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
const resultName = await uploadArtifacts(artifactClient, searchResult.filesToUpload, searchResult.rootDirectory, options, name);
|
||||||
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
resultName && uploadedArtifacts.push(resultName);
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.setFailed(err.message)
|
core.setFailed(err.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function uploadArtifacts(artifactClient: ArtifactClient, files: string[], rootDirectory: string, options: UploadOptions, name = getDefaultArtifactName()): Promise<string | undefined> {
|
||||||
|
const uploadResponse = await artifactClient.uploadArtifact(
|
||||||
|
name,
|
||||||
|
files,
|
||||||
|
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!`
|
||||||
|
)
|
||||||
|
|
||||||
|
return uploadResponse.artifactName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Add table
Reference in a new issue