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
3092
dist/index.js
vendored
3092
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,7 @@
|
|||
export enum Inputs {
|
||||
Name = 'name',
|
||||
Path = 'path'
|
||||
Path = 'path',
|
||||
SkipArchive = 'skipArchive',
|
||||
}
|
||||
|
||||
export function getDefaultArtifactName(): string {
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
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 {findFilesToUpload} from './search'
|
||||
import { basename } from 'path';
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const name = core.getInput(Inputs.Name, {required: false})
|
||||
const path = core.getInput(Inputs.Path, {required: true})
|
||||
const skipArchive = core.getInput(Inputs.SkipArchive, {required: false})
|
||||
|
||||
const searchResult = await findFilesToUpload(path)
|
||||
if (searchResult.filesToUpload.length === 0) {
|
||||
|
@ -23,10 +25,30 @@ async function run(): Promise<void> {
|
|||
const options: UploadOptions = {
|
||||
continueOnError: false
|
||||
}
|
||||
|
||||
const uploadedArtifacts: string[] = [];
|
||||
|
||||
if (skipArchive) {
|
||||
for (const file of searchResult.filesToUpload) {
|
||||
const resultName = await uploadArtifacts(artifactClient, [file], searchResult.rootDirectory, options, basename(file));
|
||||
resultName && uploadedArtifacts.push(resultName);
|
||||
}
|
||||
} else {
|
||||
const resultName = await uploadArtifacts(artifactClient, searchResult.filesToUpload, searchResult.rootDirectory, options, name);
|
||||
resultName && uploadedArtifacts.push(resultName);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (err) {
|
||||
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 || getDefaultArtifactName(),
|
||||
searchResult.filesToUpload,
|
||||
searchResult.rootDirectory,
|
||||
name,
|
||||
files,
|
||||
rootDirectory,
|
||||
options
|
||||
)
|
||||
|
||||
|
@ -38,10 +60,8 @@ async function run(): Promise<void> {
|
|||
core.info(
|
||||
`Artifact ${uploadResponse.artifactName} has been successfully uploaded!`
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
core.setFailed(err.message)
|
||||
|
||||
return uploadResponse.artifactName;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue