mirror of
https://github.com/actions/upload-artifact.git
synced 2026-04-08 16:38:25 +01:00
Compare commits
8 Commits
v7
...
428074b62c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
428074b62c | ||
|
|
15af3237b6 | ||
|
|
ffeab76ee2 | ||
|
|
6b68470975 | ||
|
|
4177a106a5 | ||
|
|
c6ec99779f | ||
|
|
e785baf943 | ||
|
|
9c47937ac2 |
38
.github/workflows/test.yml
vendored
38
.github/workflows/test.yml
vendored
@@ -10,10 +10,6 @@ on:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
actions: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
@@ -395,20 +391,27 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node 24
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24.x
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Delete test artifacts
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const keep = ['report.html'];
|
||||
const owner = context.repo.owner;
|
||||
const repo = context.repo.repo;
|
||||
const runId = context.runId;
|
||||
const artifactClient = require('@actions/artifact');
|
||||
const artifact = artifactClient.default || artifactClient;
|
||||
|
||||
const {data: {artifacts}} = await github.rest.actions.listWorkflowRunArtifacts({
|
||||
owner,
|
||||
repo,
|
||||
run_id: runId
|
||||
});
|
||||
const {artifacts} = await artifact.listArtifacts({latest: true});
|
||||
const keep = ['report.html'];
|
||||
|
||||
for (const a of artifacts) {
|
||||
if (keep.includes(a.name)) {
|
||||
@@ -416,13 +419,10 @@ jobs:
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
await github.rest.actions.deleteArtifact({
|
||||
owner,
|
||||
repo,
|
||||
artifact_id: a.id
|
||||
});
|
||||
await artifact.deleteArtifact(a.name);
|
||||
console.log(`Deleted artifact '${a.name}'`);
|
||||
} catch (err) {
|
||||
console.log(`Could not delete artifact '${a.name}': ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,57 +274,4 @@ describe('upload', () => {
|
||||
`Skipping deletion of '${fixtures.artifactName}', it does not exist`
|
||||
)
|
||||
})
|
||||
|
||||
test('passes skipArchive when archive is false', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: false
|
||||
})
|
||||
|
||||
mockFindFilesToUpload.mockResolvedValue({
|
||||
filesToUpload: [fixtures.filesToUpload[0]],
|
||||
rootDirectory: fixtures.rootDirectory
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(artifact.default.uploadArtifact).toHaveBeenCalledWith(
|
||||
fixtures.artifactName,
|
||||
[fixtures.filesToUpload[0]],
|
||||
fixtures.rootDirectory,
|
||||
{compressionLevel: 6, skipArchive: true}
|
||||
)
|
||||
})
|
||||
|
||||
test('does not pass skipArchive when archive is true', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: true
|
||||
})
|
||||
|
||||
mockFindFilesToUpload.mockResolvedValue({
|
||||
filesToUpload: [fixtures.filesToUpload[0]],
|
||||
rootDirectory: fixtures.rootDirectory
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(artifact.default.uploadArtifact).toHaveBeenCalledWith(
|
||||
fixtures.artifactName,
|
||||
[fixtures.filesToUpload[0]],
|
||||
fixtures.rootDirectory,
|
||||
{compressionLevel: 6}
|
||||
)
|
||||
})
|
||||
|
||||
test('fails when archive is false and multiple files are provided', async () => {
|
||||
mockInputs({
|
||||
[Inputs.Archive]: false
|
||||
})
|
||||
|
||||
await run()
|
||||
|
||||
expect(core.setFailed).toHaveBeenCalledWith(
|
||||
`When 'archive' is set to false, only a single file can be uploaded. Found ${fixtures.filesToUpload.length} files to upload.`
|
||||
)
|
||||
expect(artifact.default.uploadArtifact).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ description: 'Upload a build artifact that can be used by subsequent workflow st
|
||||
author: 'GitHub'
|
||||
inputs:
|
||||
name:
|
||||
description: 'Artifact name. If the `archive` input is `false`, the name of the file uploaded will be the artifact name.'
|
||||
description: 'Artifact name. If the "archive" input is `false`, the name of the file uploaded will be the artifact name.'
|
||||
default: 'artifact'
|
||||
path:
|
||||
description: 'A file, directory or wildcard pattern that describes what to upload.'
|
||||
@@ -49,7 +49,7 @@ inputs:
|
||||
description: >
|
||||
If true, the artifact will be archived (zipped) before uploading.
|
||||
If false, the artifact will be uploaded as-is without archiving.
|
||||
When `archive` is `false`, only a single file can be uploaded. The name of the file will be used as the artifact name (ignoring the `name` parameter).
|
||||
When archive is false, only a single file can be uploaded. The name of the file will be used as the artifact name.
|
||||
default: 'true'
|
||||
|
||||
outputs:
|
||||
|
||||
Reference in New Issue
Block a user