mirror of
https://github.com/actions/upload-artifact.git
synced 2026-04-09 00:12:07 +00:00
Merge 60f4f0971b into bbbca2ddaa
This commit is contained in:
commit
fbbe01cf9c
@ -327,4 +327,26 @@ describe('upload', () => {
|
|||||||
)
|
)
|
||||||
expect(artifact.default.uploadArtifact).not.toHaveBeenCalled()
|
expect(artifact.default.uploadArtifact).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('overwrite artifact by filename when archive is false', async () => {
|
||||||
|
mockInputs({
|
||||||
|
[Inputs.Archive]: false,
|
||||||
|
[Inputs.Overwrite]: true
|
||||||
|
})
|
||||||
|
|
||||||
|
mockFindFilesToUpload.mockResolvedValue({
|
||||||
|
filesToUpload: [fixtures.filesToUpload[0]],
|
||||||
|
rootDirectory: fixtures.rootDirectory
|
||||||
|
})
|
||||||
|
|
||||||
|
jest.spyOn(artifact.default, 'deleteArtifact').mockResolvedValue({
|
||||||
|
id: 1337
|
||||||
|
})
|
||||||
|
|
||||||
|
await run()
|
||||||
|
|
||||||
|
expect(artifact.default.deleteArtifact).toHaveBeenCalledWith(
|
||||||
|
fixtures.filesToUpload[0].split('/').pop() || ''
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
10
dist/upload/index.js
vendored
10
dist/upload/index.js
vendored
@ -130585,8 +130585,18 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (inputs.overwrite) {
|
if (inputs.overwrite) {
|
||||||
|
if (!inputs.archive) {
|
||||||
|
if (searchResult.filesToUpload.length > 0) {
|
||||||
|
const fileName = searchResult.filesToUpload[0].split('/').pop();
|
||||||
|
if (fileName) {
|
||||||
|
deleteArtifactIfExists(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
await deleteArtifactIfExists(inputs.artifactName);
|
await deleteArtifactIfExists(inputs.artifactName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const options = {};
|
const options = {};
|
||||||
if (inputs.retentionDays) {
|
if (inputs.retentionDays) {
|
||||||
options.retentionDays = inputs.retentionDays;
|
options.retentionDays = inputs.retentionDays;
|
||||||
|
|||||||
@ -66,8 +66,17 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inputs.overwrite) {
|
if (inputs.overwrite) {
|
||||||
|
if (!inputs.archive) {
|
||||||
|
if (searchResult.filesToUpload.length > 0) {
|
||||||
|
const fileName = searchResult.filesToUpload[0].split('/').pop()
|
||||||
|
if (fileName) {
|
||||||
|
deleteArtifactIfExists(fileName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
await deleteArtifactIfExists(inputs.artifactName)
|
await deleteArtifactIfExists(inputs.artifactName)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const options: UploadArtifactOptions = {}
|
const options: UploadArtifactOptions = {}
|
||||||
if (inputs.retentionDays) {
|
if (inputs.retentionDays) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user