mirror of
https://gitea.com/actions/upload-artifact.git
synced 2024-11-22 16:45:57 +01:00
Exclude hidden files by default
This commit is contained in:
parent
834a144ee9
commit
cb6558bb10
18 changed files with 169 additions and 36 deletions
|
@ -64,6 +64,7 @@ There is also a new sub-action, `actions/upload-artifact/merge`. For more info,
|
||||||
Due to how Artifacts are created in this new version, it is no longer possible to upload to the same named Artifact multiple times. You must either split the uploads into multiple Artifacts with different names, or only upload once. Otherwise you _will_ encounter an error.
|
Due to how Artifacts are created in this new version, it is no longer possible to upload to the same named Artifact multiple times. You must either split the uploads into multiple Artifacts with different names, or only upload once. Otherwise you _will_ encounter an error.
|
||||||
|
|
||||||
3. Limit of Artifacts for an individual job. Each job in a workflow run now has a limit of 500 artifacts.
|
3. Limit of Artifacts for an individual job. Each job in a workflow run now has a limit of 500 artifacts.
|
||||||
|
4. With `v4.4` and later, hidden files are excluded by default.
|
||||||
|
|
||||||
For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
|
For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
|
||||||
|
|
||||||
|
@ -107,6 +108,10 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
|
||||||
# Does not fail if the artifact does not exist.
|
# Does not fail if the artifact does not exist.
|
||||||
# Optional. Default is 'false'
|
# Optional. Default is 'false'
|
||||||
overwrite:
|
overwrite:
|
||||||
|
|
||||||
|
# Whether to include hidden files in the provided path in the artifact
|
||||||
|
# Optional. Default is 'false'
|
||||||
|
include-hidden-files:
|
||||||
```
|
```
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
|
@ -61,6 +61,20 @@ const lonelyFilePath = path.join(
|
||||||
'lonely-file.txt'
|
'lonely-file.txt'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const fileInHiddenFolderPath = path.join(
|
||||||
|
root,
|
||||||
|
'.hidden-folder',
|
||||||
|
'folder-in-hidden-folder',
|
||||||
|
'file.txt'
|
||||||
|
)
|
||||||
|
const hiddenFile = path.join(root, '.hidden-file.txt')
|
||||||
|
const fileInHiddenFolderInFolderA = path.join(
|
||||||
|
root,
|
||||||
|
'folder-a',
|
||||||
|
'.hidden-folder-in-folder-a',
|
||||||
|
'file.txt'
|
||||||
|
)
|
||||||
|
|
||||||
describe('Search', () => {
|
describe('Search', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// mock all output so that there is less noise when running tests
|
// mock all output so that there is less noise when running tests
|
||||||
|
@ -93,6 +107,14 @@ describe('Search', () => {
|
||||||
recursive: true
|
recursive: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await fs.mkdir(
|
||||||
|
path.join(root, '.hidden-folder', 'folder-in-hidden-folder'),
|
||||||
|
{recursive: true}
|
||||||
|
)
|
||||||
|
await fs.mkdir(path.join(root, 'folder-a', '.hidden-folder-in-folder-a'), {
|
||||||
|
recursive: true
|
||||||
|
})
|
||||||
|
|
||||||
await fs.writeFile(searchItem1Path, 'search item1 file')
|
await fs.writeFile(searchItem1Path, 'search item1 file')
|
||||||
await fs.writeFile(searchItem2Path, 'search item2 file')
|
await fs.writeFile(searchItem2Path, 'search item2 file')
|
||||||
await fs.writeFile(searchItem3Path, 'search item3 file')
|
await fs.writeFile(searchItem3Path, 'search item3 file')
|
||||||
|
@ -113,7 +135,12 @@ describe('Search', () => {
|
||||||
/*
|
/*
|
||||||
Directory structure of files that get created:
|
Directory structure of files that get created:
|
||||||
root/
|
root/
|
||||||
|
.hidden-folder/
|
||||||
|
folder-in-hidden-folder/
|
||||||
|
file.txt
|
||||||
folder-a/
|
folder-a/
|
||||||
|
.hidden-folder-in-folder-a/
|
||||||
|
file.txt
|
||||||
folder-b/
|
folder-b/
|
||||||
folder-c/
|
folder-c/
|
||||||
search-item1.txt
|
search-item1.txt
|
||||||
|
@ -136,6 +163,7 @@ describe('Search', () => {
|
||||||
folder-j/
|
folder-j/
|
||||||
folder-k/
|
folder-k/
|
||||||
lonely-file.txt
|
lonely-file.txt
|
||||||
|
.hidden-file.txt
|
||||||
search-item5.txt
|
search-item5.txt
|
||||||
*/
|
*/
|
||||||
})
|
})
|
||||||
|
@ -352,4 +380,30 @@ describe('Search', () => {
|
||||||
)
|
)
|
||||||
expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true)
|
expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Hidden files ignored by default', async () => {
|
||||||
|
const searchPath = path.join(root, '**/*')
|
||||||
|
const searchResult = await findFilesToUpload(searchPath)
|
||||||
|
|
||||||
|
expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false)
|
||||||
|
expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA)
|
||||||
|
).toEqual(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Hidden files included', async () => {
|
||||||
|
const searchPath = path.join(root, '**/*')
|
||||||
|
const searchResult = await findFilesToUpload(searchPath, true)
|
||||||
|
|
||||||
|
expect(searchResult.filesToUpload.includes(hiddenFile)).toEqual(false)
|
||||||
|
expect(searchResult.filesToUpload.includes(fileInHiddenFolderPath)).toEqual(
|
||||||
|
false
|
||||||
|
)
|
||||||
|
expect(
|
||||||
|
searchResult.filesToUpload.includes(fileInHiddenFolderInFolderA)
|
||||||
|
).toEqual(false)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -40,6 +40,11 @@ inputs:
|
||||||
If false, the action will fail if an artifact for the given name already exists.
|
If false, the action will fail if an artifact for the given name already exists.
|
||||||
Does not fail if the artifact does not exist.
|
Does not fail if the artifact does not exist.
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
include-hidden-files:
|
||||||
|
description: >
|
||||||
|
If true, hidden files will be included in the merged artifact.
|
||||||
|
If false, hidden files will be excluded from the merged artifact.
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
artifact-id:
|
artifact-id:
|
||||||
|
|
16
dist/merge/index.js
vendored
16
dist/merge/index.js
vendored
|
@ -125727,6 +125727,7 @@ var Inputs;
|
||||||
Inputs["RetentionDays"] = "retention-days";
|
Inputs["RetentionDays"] = "retention-days";
|
||||||
Inputs["CompressionLevel"] = "compression-level";
|
Inputs["CompressionLevel"] = "compression-level";
|
||||||
Inputs["DeleteMerged"] = "delete-merged";
|
Inputs["DeleteMerged"] = "delete-merged";
|
||||||
|
Inputs["IncludeHiddenFiles"] = "include-hidden-files";
|
||||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||||
|
|
||||||
|
|
||||||
|
@ -125810,13 +125811,15 @@ function getInputs() {
|
||||||
const pattern = core.getInput(constants_1.Inputs.Pattern, { required: true });
|
const pattern = core.getInput(constants_1.Inputs.Pattern, { required: true });
|
||||||
const separateDirectories = core.getBooleanInput(constants_1.Inputs.SeparateDirectories);
|
const separateDirectories = core.getBooleanInput(constants_1.Inputs.SeparateDirectories);
|
||||||
const deleteMerged = core.getBooleanInput(constants_1.Inputs.DeleteMerged);
|
const deleteMerged = core.getBooleanInput(constants_1.Inputs.DeleteMerged);
|
||||||
|
const includeHiddenFiles = core.getBooleanInput(constants_1.Inputs.IncludeHiddenFiles);
|
||||||
const inputs = {
|
const inputs = {
|
||||||
name,
|
name,
|
||||||
pattern,
|
pattern,
|
||||||
separateDirectories,
|
separateDirectories,
|
||||||
deleteMerged,
|
deleteMerged,
|
||||||
retentionDays: 0,
|
retentionDays: 0,
|
||||||
compressionLevel: 6
|
compressionLevel: 6,
|
||||||
|
includeHiddenFiles,
|
||||||
};
|
};
|
||||||
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
|
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
|
||||||
if (retentionDaysStr) {
|
if (retentionDaysStr) {
|
||||||
|
@ -125932,7 +125935,7 @@ function run() {
|
||||||
if (typeof inputs.compressionLevel !== 'undefined') {
|
if (typeof inputs.compressionLevel !== 'undefined') {
|
||||||
options.compressionLevel = inputs.compressionLevel;
|
options.compressionLevel = inputs.compressionLevel;
|
||||||
}
|
}
|
||||||
const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir);
|
const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir, inputs.includeHiddenFiles);
|
||||||
yield (0, upload_artifact_1.uploadArtifact)(inputs.name, searchResult.filesToUpload, searchResult.rootDirectory, options);
|
yield (0, upload_artifact_1.uploadArtifact)(inputs.name, searchResult.filesToUpload, searchResult.rootDirectory, options);
|
||||||
core.info(`The ${artifacts.length} artifact(s) have been successfully merged!`);
|
core.info(`The ${artifacts.length} artifact(s) have been successfully merged!`);
|
||||||
if (inputs.deleteMerged) {
|
if (inputs.deleteMerged) {
|
||||||
|
@ -125999,11 +126002,12 @@ const fs_1 = __nccwpck_require__(57147);
|
||||||
const path_1 = __nccwpck_require__(71017);
|
const path_1 = __nccwpck_require__(71017);
|
||||||
const util_1 = __nccwpck_require__(73837);
|
const util_1 = __nccwpck_require__(73837);
|
||||||
const stats = (0, util_1.promisify)(fs_1.stat);
|
const stats = (0, util_1.promisify)(fs_1.stat);
|
||||||
function getDefaultGlobOptions() {
|
function getDefaultGlobOptions(_includeHiddenFiles) {
|
||||||
return {
|
return {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
implicitDescendants: true,
|
implicitDescendants: true,
|
||||||
omitBrokenSymbolicLinks: true
|
omitBrokenSymbolicLinks: true,
|
||||||
|
// excludeHiddenFiles: !includeHiddenFiles,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -126057,10 +126061,10 @@ function getMultiPathLCA(searchPaths) {
|
||||||
}
|
}
|
||||||
return path.join(...commonPaths);
|
return path.join(...commonPaths);
|
||||||
}
|
}
|
||||||
function findFilesToUpload(searchPath, globOptions) {
|
function findFilesToUpload(searchPath, includeHiddenFiles) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const searchResults = [];
|
const searchResults = [];
|
||||||
const globber = yield glob.create(searchPath, globOptions || getDefaultGlobOptions());
|
const globber = yield glob.create(searchPath, getDefaultGlobOptions(includeHiddenFiles || false));
|
||||||
const rawSearchResults = yield globber.glob();
|
const rawSearchResults = yield globber.glob();
|
||||||
/*
|
/*
|
||||||
Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten
|
Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten
|
||||||
|
|
16
dist/upload/index.js
vendored
16
dist/upload/index.js
vendored
|
@ -125757,11 +125757,12 @@ const fs_1 = __nccwpck_require__(57147);
|
||||||
const path_1 = __nccwpck_require__(71017);
|
const path_1 = __nccwpck_require__(71017);
|
||||||
const util_1 = __nccwpck_require__(73837);
|
const util_1 = __nccwpck_require__(73837);
|
||||||
const stats = (0, util_1.promisify)(fs_1.stat);
|
const stats = (0, util_1.promisify)(fs_1.stat);
|
||||||
function getDefaultGlobOptions() {
|
function getDefaultGlobOptions(_includeHiddenFiles) {
|
||||||
return {
|
return {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
implicitDescendants: true,
|
implicitDescendants: true,
|
||||||
omitBrokenSymbolicLinks: true
|
omitBrokenSymbolicLinks: true,
|
||||||
|
// excludeHiddenFiles: !includeHiddenFiles,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -125815,10 +125816,10 @@ function getMultiPathLCA(searchPaths) {
|
||||||
}
|
}
|
||||||
return path.join(...commonPaths);
|
return path.join(...commonPaths);
|
||||||
}
|
}
|
||||||
function findFilesToUpload(searchPath, globOptions) {
|
function findFilesToUpload(searchPath, includeHiddenFiles) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const searchResults = [];
|
const searchResults = [];
|
||||||
const globber = yield glob.create(searchPath, globOptions || getDefaultGlobOptions());
|
const globber = yield glob.create(searchPath, getDefaultGlobOptions(includeHiddenFiles || false));
|
||||||
const rawSearchResults = yield globber.glob();
|
const rawSearchResults = yield globber.glob();
|
||||||
/*
|
/*
|
||||||
Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten
|
Files are saved with case insensitivity. Uploading both a.txt and A.txt will files to be overwritten
|
||||||
|
@ -125956,6 +125957,7 @@ var Inputs;
|
||||||
Inputs["RetentionDays"] = "retention-days";
|
Inputs["RetentionDays"] = "retention-days";
|
||||||
Inputs["CompressionLevel"] = "compression-level";
|
Inputs["CompressionLevel"] = "compression-level";
|
||||||
Inputs["Overwrite"] = "overwrite";
|
Inputs["Overwrite"] = "overwrite";
|
||||||
|
Inputs["IncludeHiddenFiles"] = "include-hidden-files";
|
||||||
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
})(Inputs = exports.Inputs || (exports.Inputs = {}));
|
||||||
var NoFileOptions;
|
var NoFileOptions;
|
||||||
(function (NoFileOptions) {
|
(function (NoFileOptions) {
|
||||||
|
@ -126053,6 +126055,7 @@ function getInputs() {
|
||||||
const name = core.getInput(constants_1.Inputs.Name);
|
const name = core.getInput(constants_1.Inputs.Name);
|
||||||
const path = core.getInput(constants_1.Inputs.Path, { required: true });
|
const path = core.getInput(constants_1.Inputs.Path, { required: true });
|
||||||
const overwrite = core.getBooleanInput(constants_1.Inputs.Overwrite);
|
const overwrite = core.getBooleanInput(constants_1.Inputs.Overwrite);
|
||||||
|
const includeHiddenFiles = core.getBooleanInput(constants_1.Inputs.IncludeHiddenFiles);
|
||||||
const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound);
|
const ifNoFilesFound = core.getInput(constants_1.Inputs.IfNoFilesFound);
|
||||||
const noFileBehavior = constants_1.NoFileOptions[ifNoFilesFound];
|
const noFileBehavior = constants_1.NoFileOptions[ifNoFilesFound];
|
||||||
if (!noFileBehavior) {
|
if (!noFileBehavior) {
|
||||||
|
@ -126062,7 +126065,8 @@ function getInputs() {
|
||||||
artifactName: name,
|
artifactName: name,
|
||||||
searchPath: path,
|
searchPath: path,
|
||||||
ifNoFilesFound: noFileBehavior,
|
ifNoFilesFound: noFileBehavior,
|
||||||
overwrite: overwrite
|
overwrite: overwrite,
|
||||||
|
includeHiddenFiles: includeHiddenFiles,
|
||||||
};
|
};
|
||||||
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
|
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
|
||||||
if (retentionDaysStr) {
|
if (retentionDaysStr) {
|
||||||
|
@ -126151,7 +126155,7 @@ function deleteArtifactIfExists(artifactName) {
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const inputs = (0, input_helper_1.getInputs)();
|
const inputs = (0, input_helper_1.getInputs)();
|
||||||
const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath);
|
const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath, inputs.includeHiddenFiles);
|
||||||
if (searchResult.filesToUpload.length === 0) {
|
if (searchResult.filesToUpload.length === 0) {
|
||||||
// No files were found, different use cases warrant different types of behavior if nothing is found
|
// No files were found, different use cases warrant different types of behavior if nothing is found
|
||||||
switch (inputs.ifNoFilesFound) {
|
switch (inputs.ifNoFilesFound) {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
- [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact)
|
- [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact)
|
||||||
- [Overwriting an Artifact](#overwriting-an-artifact)
|
- [Overwriting an Artifact](#overwriting-an-artifact)
|
||||||
- [Merging multiple artifacts](#merging-multiple-artifacts)
|
- [Merging multiple artifacts](#merging-multiple-artifacts)
|
||||||
|
- [Hidden files](#hidden-files)
|
||||||
|
|
||||||
Several behavioral differences exist between Artifact actions `v3` and below vs `v4`. This document outlines common scenarios in `v3`, and how they would be handled in `v4`.
|
Several behavioral differences exist between Artifact actions `v3` and below vs `v4`. This document outlines common scenarios in `v3`, and how they would be handled in `v4`.
|
||||||
|
|
||||||
|
@ -189,21 +190,59 @@ jobs:
|
||||||
- name: Create a File
|
- name: Create a File
|
||||||
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
|
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
+ uses: actions/upload-artifact@v4
|
+ uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
- name: all-my-files
|
- name: all-my-files
|
||||||
+ name: my-artifact-${{ matrix.runs-on }}
|
+ name: my-artifact-${{ matrix.runs-on }}
|
||||||
path: file-${{ matrix.runs-on }}.txt
|
path: file-${{ matrix.runs-on }}.txt
|
||||||
+ merge:
|
+ merge:
|
||||||
+ runs-on: ubuntu-latest
|
+ runs-on: ubuntu-latest
|
||||||
+ needs: upload
|
+ needs: upload
|
||||||
+ steps:
|
+ steps:
|
||||||
+ - name: Merge Artifacts
|
+ - name: Merge Artifacts
|
||||||
+ uses: actions/upload-artifact/merge@v4
|
+ uses: actions/upload-artifact/merge@v4
|
||||||
+ with:
|
+ with:
|
||||||
+ name: all-my-files
|
+ name: all-my-files
|
||||||
+ pattern: my-artifact-*
|
+ pattern: my-artifact-*
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that this will download all artifacts to a temporary directory and reupload them as a single artifact. For more information on inputs and other use cases for `actions/upload-artifact/merge@v4`, see [the action documentation](../merge/README.md).
|
Note that this will download all artifacts to a temporary directory and reupload them as a single artifact. For more information on inputs and other use cases for `actions/upload-artifact/merge@v4`, see [the action documentation](../merge/README.md).
|
||||||
|
|
||||||
|
## Hidden Files
|
||||||
|
|
||||||
|
By default, hidden files are ignored by this action to avoid unintentionally uploading sensitive
|
||||||
|
information.
|
||||||
|
|
||||||
|
In versions of this action before v4.4.0, these hidden files were included by default.
|
||||||
|
|
||||||
|
If you need to upload hidden files, you can use the `include-hidden-files` input.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
upload:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create a Hidden File
|
||||||
|
run: echo "hello from a hidden file" > .hidden-file.txt
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
path: .hidden-file.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```diff
|
||||||
|
jobs:
|
||||||
|
upload:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create a Hidden File
|
||||||
|
run: echo "hello from a hidden file" > .hidden-file.txt
|
||||||
|
- name: Upload Artifact
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
+ uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
path: .hidden-file.txt
|
||||||
|
+ include-hidden-files: true
|
||||||
|
```
|
|
@ -36,6 +36,11 @@ inputs:
|
||||||
If true, the artifacts that were merged will be deleted.
|
If true, the artifacts that were merged will be deleted.
|
||||||
If false, the artifacts will still exist.
|
If false, the artifacts will still exist.
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
include-hidden-files:
|
||||||
|
description: >
|
||||||
|
If true, hidden files will be included in the merged artifact.
|
||||||
|
If false, hidden files will be excluded from the merged artifact.
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
artifact-id:
|
artifact-id:
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "upload-artifact",
|
"name": "upload-artifact",
|
||||||
"version": "4.3.6",
|
"version": "4.4.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "upload-artifact",
|
"name": "upload-artifact",
|
||||||
"version": "4.3.6",
|
"version": "4.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "2.1.8",
|
"@actions/artifact": "2.1.8",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "upload-artifact",
|
"name": "upload-artifact",
|
||||||
"version": "4.3.6",
|
"version": "4.4.0",
|
||||||
"description": "Upload an Actions Artifact in a workflow run",
|
"description": "Upload an Actions Artifact in a workflow run",
|
||||||
"main": "dist/upload/index.js",
|
"main": "dist/upload/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -5,5 +5,6 @@ export enum Inputs {
|
||||||
SeparateDirectories = 'separate-directories',
|
SeparateDirectories = 'separate-directories',
|
||||||
RetentionDays = 'retention-days',
|
RetentionDays = 'retention-days',
|
||||||
CompressionLevel = 'compression-level',
|
CompressionLevel = 'compression-level',
|
||||||
DeleteMerged = 'delete-merged'
|
DeleteMerged = 'delete-merged',
|
||||||
|
IncludeHiddenFiles = 'include-hidden-files',
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ export function getInputs(): MergeInputs {
|
||||||
const pattern = core.getInput(Inputs.Pattern, {required: true})
|
const pattern = core.getInput(Inputs.Pattern, {required: true})
|
||||||
const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
|
const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
|
||||||
const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
|
const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
|
||||||
|
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||||
|
|
||||||
const inputs = {
|
const inputs = {
|
||||||
name,
|
name,
|
||||||
|
@ -17,7 +18,8 @@ export function getInputs(): MergeInputs {
|
||||||
separateDirectories,
|
separateDirectories,
|
||||||
deleteMerged,
|
deleteMerged,
|
||||||
retentionDays: 0,
|
retentionDays: 0,
|
||||||
compressionLevel: 6
|
compressionLevel: 6,
|
||||||
|
includeHiddenFiles,
|
||||||
} as MergeInputs
|
} as MergeInputs
|
||||||
|
|
||||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||||
|
|
|
@ -62,7 +62,7 @@ export async function run(): Promise<void> {
|
||||||
options.compressionLevel = inputs.compressionLevel
|
options.compressionLevel = inputs.compressionLevel
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchResult = await findFilesToUpload(tmpDir)
|
const searchResult = await findFilesToUpload(tmpDir, inputs.includeHiddenFiles)
|
||||||
|
|
||||||
await uploadArtifact(
|
await uploadArtifact(
|
||||||
inputs.name,
|
inputs.name,
|
||||||
|
|
|
@ -30,4 +30,9 @@ export interface MergeInputs {
|
||||||
* If false, the artifacts will be merged into the root of the destination.
|
* If false, the artifacts will be merged into the root of the destination.
|
||||||
*/
|
*/
|
||||||
separateDirectories: boolean
|
separateDirectories: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to include hidden files in the artifact
|
||||||
|
*/
|
||||||
|
includeHiddenFiles: boolean
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,12 @@ export interface SearchResult {
|
||||||
rootDirectory: string
|
rootDirectory: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultGlobOptions(): glob.GlobOptions {
|
function getDefaultGlobOptions(_includeHiddenFiles: boolean): glob.GlobOptions {
|
||||||
return {
|
return {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
implicitDescendants: true,
|
implicitDescendants: true,
|
||||||
omitBrokenSymbolicLinks: true
|
omitBrokenSymbolicLinks: true,
|
||||||
|
// excludeHiddenFiles: !includeHiddenFiles,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +81,12 @@ function getMultiPathLCA(searchPaths: string[]): string {
|
||||||
|
|
||||||
export async function findFilesToUpload(
|
export async function findFilesToUpload(
|
||||||
searchPath: string,
|
searchPath: string,
|
||||||
globOptions?: glob.GlobOptions
|
includeHiddenFiles?: boolean,
|
||||||
): Promise<SearchResult> {
|
): Promise<SearchResult> {
|
||||||
const searchResults: string[] = []
|
const searchResults: string[] = []
|
||||||
const globber = await glob.create(
|
const globber = await glob.create(
|
||||||
searchPath,
|
searchPath,
|
||||||
globOptions || getDefaultGlobOptions()
|
getDefaultGlobOptions(includeHiddenFiles || false)
|
||||||
)
|
)
|
||||||
const rawSearchResults: string[] = await globber.glob()
|
const rawSearchResults: string[] = await globber.glob()
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ export enum Inputs {
|
||||||
IfNoFilesFound = 'if-no-files-found',
|
IfNoFilesFound = 'if-no-files-found',
|
||||||
RetentionDays = 'retention-days',
|
RetentionDays = 'retention-days',
|
||||||
CompressionLevel = 'compression-level',
|
CompressionLevel = 'compression-level',
|
||||||
Overwrite = 'overwrite'
|
Overwrite = 'overwrite',
|
||||||
|
IncludeHiddenFiles = 'include-hidden-files',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NoFileOptions {
|
export enum NoFileOptions {
|
||||||
|
|
|
@ -9,6 +9,7 @@ export function getInputs(): UploadInputs {
|
||||||
const name = core.getInput(Inputs.Name)
|
const name = core.getInput(Inputs.Name)
|
||||||
const path = core.getInput(Inputs.Path, {required: true})
|
const path = core.getInput(Inputs.Path, {required: true})
|
||||||
const overwrite = core.getBooleanInput(Inputs.Overwrite)
|
const overwrite = core.getBooleanInput(Inputs.Overwrite)
|
||||||
|
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
|
||||||
|
|
||||||
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
|
||||||
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
|
||||||
|
@ -27,7 +28,8 @@ export function getInputs(): UploadInputs {
|
||||||
artifactName: name,
|
artifactName: name,
|
||||||
searchPath: path,
|
searchPath: path,
|
||||||
ifNoFilesFound: noFileBehavior,
|
ifNoFilesFound: noFileBehavior,
|
||||||
overwrite: overwrite
|
overwrite: overwrite,
|
||||||
|
includeHiddenFiles: includeHiddenFiles,
|
||||||
} as UploadInputs
|
} as UploadInputs
|
||||||
|
|
||||||
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
||||||
|
|
|
@ -24,7 +24,7 @@ async function deleteArtifactIfExists(artifactName: string): Promise<void> {
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
const searchResult = await findFilesToUpload(inputs.searchPath)
|
const searchResult = await findFilesToUpload(inputs.searchPath, inputs.includeHiddenFiles)
|
||||||
if (searchResult.filesToUpload.length === 0) {
|
if (searchResult.filesToUpload.length === 0) {
|
||||||
// No files were found, different use cases warrant different types of behavior if nothing is found
|
// No files were found, different use cases warrant different types of behavior if nothing is found
|
||||||
switch (inputs.ifNoFilesFound) {
|
switch (inputs.ifNoFilesFound) {
|
||||||
|
|
|
@ -30,4 +30,9 @@ export interface UploadInputs {
|
||||||
* Whether or not to replace an existing artifact with the same name
|
* Whether or not to replace an existing artifact with the same name
|
||||||
*/
|
*/
|
||||||
overwrite: boolean
|
overwrite: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to include hidden files in the artifact
|
||||||
|
*/
|
||||||
|
includeHiddenFiles: boolean
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue