Compare commits

..

3 Commits

Author SHA1 Message Date
Josh Gross
f626d210e8 linting 2024-08-15 20:37:17 -04:00
Josh Gross
fa37431cef npm ci and npm run release 2024-08-15 20:34:01 -04:00
Josh Gross
3412bb46a4 Exclude the .git directory by default 2024-08-15 20:29:20 -04:00
20 changed files with 324 additions and 325 deletions

View File

@@ -1,6 +1,6 @@
--- ---
name: "@actions/glob" name: "@actions/glob"
version: 0.5.0 version: 0.3.0
type: npm type: npm
summary: summary:
homepage: homepage:

View File

@@ -16,6 +16,7 @@ See also [download-artifact](https://github.com/actions/download-artifact).
- [Breaking Changes](#breaking-changes) - [Breaking Changes](#breaking-changes)
- [Usage](#usage) - [Usage](#usage)
- [Inputs](#inputs) - [Inputs](#inputs)
- [Uploading the `.git` directory](#uploading-the-git-directory)
- [Outputs](#outputs) - [Outputs](#outputs)
- [Examples](#examples) - [Examples](#examples)
- [Upload an Individual File](#upload-an-individual-file) - [Upload an Individual File](#upload-an-individual-file)
@@ -64,7 +65,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. 4. With `v4.4` and later, the `.git` directory is 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).
@@ -108,12 +109,30 @@ 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 #### Uploading the `.git` directory
# The file contents of any hidden files in the path should be validated before
# enabled this to avoid uploading sensitive information. By default, files in a `.git` directory are ignored in the uploaded artifact.
# Optional. Default is 'false' This is intended to prevent accidentally uploading Git credentials into an artifact that could then
include-hidden-files: be extracted.
If files in the `.git` directory are needed, ensure that `actions/checkout` is being used with
`persist-credentials: false`.
```yaml
jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # Ensure credentials are not saved in `.git/config`
- uses: actions/upload-artifact@v4
with:
path: .
include-git-directory: true
``` ```
### Outputs ### Outputs

View File

@@ -61,19 +61,11 @@ const lonelyFilePath = path.join(
'lonely-file.txt' 'lonely-file.txt'
) )
const hiddenFile = path.join(root, '.hidden-file.txt') const gitConfigPath = path.join(root, '.git', 'config')
const fileInHiddenFolderPath = path.join( const gitHeadPath = path.join(root, '.git', 'HEAD')
root,
'.hidden-folder', const nestedGitConfigPath = path.join(root, 'repository-name', '.git', 'config')
'folder-in-hidden-folder', const nestedGitHeadPath = path.join(root, 'repository-name', '.git', 'HEAD')
'file.txt'
)
const fileInHiddenFolderInFolderA = path.join(
root,
'folder-a',
'.hidden-folder-in-folder-a',
'file.txt'
)
describe('Search', () => { describe('Search', () => {
beforeAll(async () => { beforeAll(async () => {
@@ -107,11 +99,8 @@ describe('Search', () => {
recursive: true recursive: true
}) })
await fs.mkdir( await fs.mkdir(path.join(root, '.git'))
path.join(root, '.hidden-folder', 'folder-in-hidden-folder'), await fs.mkdir(path.join(root, 'repository-name', '.git'), {
{recursive: true}
)
await fs.mkdir(path.join(root, 'folder-a', '.hidden-folder-in-folder-a'), {
recursive: true recursive: true
}) })
@@ -133,18 +122,17 @@ describe('Search', () => {
await fs.writeFile(lonelyFilePath, 'all by itself') await fs.writeFile(lonelyFilePath, 'all by itself')
await fs.writeFile(hiddenFile, 'hidden file') await fs.writeFile(gitConfigPath, 'git config file')
await fs.writeFile(fileInHiddenFolderPath, 'file in hidden directory') await fs.writeFile(gitHeadPath, 'git head file')
await fs.writeFile(fileInHiddenFolderInFolderA, 'file in hidden directory') await fs.writeFile(nestedGitConfigPath, 'nested git config file')
await fs.writeFile(nestedGitHeadPath, 'nested git head file')
/* /*
Directory structure of files that get created: Directory structure of files that get created:
root/ root/
.hidden-folder/ .git/
folder-in-hidden-folder/ config
file.txt HEAD
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
@@ -167,7 +155,10 @@ describe('Search', () => {
folder-j/ folder-j/
folder-k/ folder-k/
lonely-file.txt lonely-file.txt
.hidden-file.txt repository-name/
.git/
config
HEAD
search-item5.txt search-item5.txt
*/ */
}) })
@@ -385,23 +376,17 @@ describe('Search', () => {
expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true) expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true)
}) })
it('Hidden files ignored by default', async () => { it('Excludes .git directory by default', async () => {
const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(root)
const searchResult = await findFilesToUpload(searchPath) expect(searchResult.filesToUpload.length).toEqual(13)
expect(searchResult.filesToUpload).not.toContain(gitConfigPath)
expect(searchResult.filesToUpload).not.toContain(hiddenFile)
expect(searchResult.filesToUpload).not.toContain(fileInHiddenFolderPath)
expect(searchResult.filesToUpload).not.toContain(
fileInHiddenFolderInFolderA
)
}) })
it('Hidden files included', async () => { it('Includes .git directory when includeGitDirectory is true', async () => {
const searchPath = path.join(root, '**/*') const searchResult = await findFilesToUpload(root, {
const searchResult = await findFilesToUpload(searchPath, true) includeGitDirectory: true
})
expect(searchResult.filesToUpload).toContain(hiddenFile) expect(searchResult.filesToUpload.length).toEqual(17)
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath) expect(searchResult.filesToUpload).toContain(gitConfigPath)
expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA)
}) })
}) })

View File

@@ -40,10 +40,8 @@ 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: include-git-directory:
description: > description: 'Include files in the .git directory in the artifact.'
If true, hidden files will be included in the artifact.
If false, hidden files will be excluded from the artifact.
default: 'false' default: 'false'
outputs: outputs:

174
dist/merge/index.js vendored
View File

@@ -8881,18 +8881,16 @@ exports.create = create;
* Computes the sha256 hash of a glob * Computes the sha256 hash of a glob
* *
* @param patterns Patterns separated by newlines * @param patterns Patterns separated by newlines
* @param currentWorkspace Workspace used when matching files
* @param options Glob options * @param options Glob options
* @param verbose Enables verbose logging
*/ */
function hashFiles(patterns, currentWorkspace = '', options, verbose = false) { function hashFiles(patterns, options, verbose = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let followSymbolicLinks = true; let followSymbolicLinks = true;
if (options && typeof options.followSymbolicLinks === 'boolean') { if (options && typeof options.followSymbolicLinks === 'boolean') {
followSymbolicLinks = options.followSymbolicLinks; followSymbolicLinks = options.followSymbolicLinks;
} }
const globber = yield create(patterns, { followSymbolicLinks }); const globber = yield create(patterns, { followSymbolicLinks });
return (0, internal_hash_files_1.hashFiles)(globber, currentWorkspace, verbose); return internal_hash_files_1.hashFiles(globber, verbose);
}); });
} }
exports.hashFiles = hashFiles; exports.hashFiles = hashFiles;
@@ -8907,11 +8905,7 @@ exports.hashFiles = hashFiles;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8924,7 +8918,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8939,8 +8933,7 @@ function getOptions(copy) {
followSymbolicLinks: true, followSymbolicLinks: true,
implicitDescendants: true, implicitDescendants: true,
matchDirectories: true, matchDirectories: true,
omitBrokenSymbolicLinks: true, omitBrokenSymbolicLinks: true
excludeHiddenFiles: false
}; };
if (copy) { if (copy) {
if (typeof copy.followSymbolicLinks === 'boolean') { if (typeof copy.followSymbolicLinks === 'boolean') {
@@ -8959,10 +8952,6 @@ function getOptions(copy) {
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks;
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`);
} }
if (typeof copy.excludeHiddenFiles === 'boolean') {
result.excludeHiddenFiles = copy.excludeHiddenFiles;
core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`);
}
} }
return result; return result;
} }
@@ -8978,11 +8967,7 @@ exports.getOptions = getOptions;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8995,7 +8980,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9049,21 +9034,19 @@ class DefaultGlobber {
return this.searchPaths.slice(); return this.searchPaths.slice();
} }
glob() { glob() {
var _a, e_1, _b, _c; var e_1, _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const result = []; const result = [];
try { try {
for (var _d = true, _e = __asyncValues(this.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { for (var _b = __asyncValues(this.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
_c = _f.value; const itemPath = _c.value;
_d = false;
const itemPath = _c;
result.push(itemPath); result.push(itemPath);
} }
} }
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
@@ -9121,10 +9104,6 @@ class DefaultGlobber {
if (!stats) { if (!stats) {
continue; continue;
} }
// Hidden file or directory?
if (options.excludeHiddenFiles && path.basename(item.path).match(/^\./)) {
continue;
}
// Directory // Directory
if (stats.isDirectory()) { if (stats.isDirectory()) {
// Matched // Matched
@@ -9230,11 +9209,7 @@ exports.DefaultGlobber = DefaultGlobber;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9247,7 +9222,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9275,22 +9250,18 @@ const fs = __importStar(__nccwpck_require__(57147));
const stream = __importStar(__nccwpck_require__(12781)); const stream = __importStar(__nccwpck_require__(12781));
const util = __importStar(__nccwpck_require__(73837)); const util = __importStar(__nccwpck_require__(73837));
const path = __importStar(__nccwpck_require__(71017)); const path = __importStar(__nccwpck_require__(71017));
function hashFiles(globber, currentWorkspace, verbose = false) { function hashFiles(globber, verbose = false) {
var _a, e_1, _b, _c; var e_1, _a;
var _d; var _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const writeDelegate = verbose ? core.info : core.debug; const writeDelegate = verbose ? core.info : core.debug;
let hasMatch = false; let hasMatch = false;
const githubWorkspace = currentWorkspace const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
? currentWorkspace
: (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd();
const result = crypto.createHash('sha256'); const result = crypto.createHash('sha256');
let count = 0; let count = 0;
try { try {
for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
_c = _g.value; const file = _d.value;
_e = false;
const file = _c;
writeDelegate(file); writeDelegate(file);
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) { if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
@@ -9313,7 +9284,7 @@ function hashFiles(globber, currentWorkspace, verbose = false) {
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f); if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
@@ -9353,7 +9324,7 @@ var MatchKind;
MatchKind[MatchKind["File"] = 2] = "File"; MatchKind[MatchKind["File"] = 2] = "File";
/** Matched */ /** Matched */
MatchKind[MatchKind["All"] = 3] = "All"; MatchKind[MatchKind["All"] = 3] = "All";
})(MatchKind || (exports.MatchKind = MatchKind = {})); })(MatchKind = exports.MatchKind || (exports.MatchKind = {}));
//# sourceMappingURL=internal-match-kind.js.map //# sourceMappingURL=internal-match-kind.js.map
/***/ }), /***/ }),
@@ -9365,11 +9336,7 @@ var MatchKind;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9382,7 +9349,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9432,8 +9399,8 @@ exports.dirname = dirname;
* or `C:` are expanded based on the current working directory. * or `C:` are expanded based on the current working directory.
*/ */
function ensureAbsoluteRoot(root, itemPath) { function ensureAbsoluteRoot(root, itemPath) {
(0, assert_1.default)(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`);
(0, assert_1.default)(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`);
// Already rooted // Already rooted
if (hasAbsoluteRoot(itemPath)) { if (hasAbsoluteRoot(itemPath)) {
return itemPath; return itemPath;
@@ -9443,7 +9410,7 @@ function ensureAbsoluteRoot(root, itemPath) {
// Check for itemPath like C: or C:foo // Check for itemPath like C: or C:foo
if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) { if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) {
let cwd = process.cwd(); let cwd = process.cwd();
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
// Drive letter matches cwd? Expand to cwd // Drive letter matches cwd? Expand to cwd
if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) { if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) {
// Drive only, e.g. C: // Drive only, e.g. C:
@@ -9468,11 +9435,11 @@ function ensureAbsoluteRoot(root, itemPath) {
// Check for itemPath like \ or \foo // Check for itemPath like \ or \foo
else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) { else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) {
const cwd = process.cwd(); const cwd = process.cwd();
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
return `${cwd[0]}:\\${itemPath.substr(1)}`; return `${cwd[0]}:\\${itemPath.substr(1)}`;
} }
} }
(0, assert_1.default)(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`);
// Otherwise ensure root ends with a separator // Otherwise ensure root ends with a separator
if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) { if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) {
// Intentionally empty // Intentionally empty
@@ -9489,7 +9456,7 @@ exports.ensureAbsoluteRoot = ensureAbsoluteRoot;
* `\\hello\share` and `C:\hello` (and using alternate separator). * `\\hello\share` and `C:\hello` (and using alternate separator).
*/ */
function hasAbsoluteRoot(itemPath) { function hasAbsoluteRoot(itemPath) {
(0, assert_1.default)(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`);
// Normalize separators // Normalize separators
itemPath = normalizeSeparators(itemPath); itemPath = normalizeSeparators(itemPath);
// Windows // Windows
@@ -9506,7 +9473,7 @@ exports.hasAbsoluteRoot = hasAbsoluteRoot;
* `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator). * `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator).
*/ */
function hasRoot(itemPath) { function hasRoot(itemPath) {
(0, assert_1.default)(itemPath, `isRooted parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`);
// Normalize separators // Normalize separators
itemPath = normalizeSeparators(itemPath); itemPath = normalizeSeparators(itemPath);
// Windows // Windows
@@ -9574,11 +9541,7 @@ exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9591,7 +9554,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9616,7 +9579,7 @@ class Path {
this.segments = []; this.segments = [];
// String // String
if (typeof itemPath === 'string') { if (typeof itemPath === 'string') {
(0, assert_1.default)(itemPath, `Parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`);
// Normalize slashes and trim unnecessary trailing slash // Normalize slashes and trim unnecessary trailing slash
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
// Not rooted // Not rooted
@@ -9643,24 +9606,24 @@ class Path {
// Array // Array
else { else {
// Must not be empty // Must not be empty
(0, assert_1.default)(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`);
// Each segment // Each segment
for (let i = 0; i < itemPath.length; i++) { for (let i = 0; i < itemPath.length; i++) {
let segment = itemPath[i]; let segment = itemPath[i];
// Must not be empty // Must not be empty
(0, assert_1.default)(segment, `Parameter 'itemPath' must not contain any empty segments`); assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`);
// Normalize slashes // Normalize slashes
segment = pathHelper.normalizeSeparators(itemPath[i]); segment = pathHelper.normalizeSeparators(itemPath[i]);
// Root segment // Root segment
if (i === 0 && pathHelper.hasRoot(segment)) { if (i === 0 && pathHelper.hasRoot(segment)) {
segment = pathHelper.safeTrimTrailingSeparator(segment); segment = pathHelper.safeTrimTrailingSeparator(segment);
(0, assert_1.default)(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`);
this.segments.push(segment); this.segments.push(segment);
} }
// All other segments // All other segments
else { else {
// Must not contain slash // Must not contain slash
(0, assert_1.default)(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`);
this.segments.push(segment); this.segments.push(segment);
} }
} }
@@ -9698,11 +9661,7 @@ exports.Path = Path;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9715,7 +9674,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9803,11 +9762,7 @@ exports.partialMatch = partialMatch;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9820,7 +9775,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9852,9 +9807,9 @@ class Pattern {
else { else {
// Convert to pattern // Convert to pattern
segments = segments || []; segments = segments || [];
(0, assert_1.default)(segments.length, `Parameter 'segments' must not empty`); assert_1.default(segments.length, `Parameter 'segments' must not empty`);
const root = Pattern.getLiteral(segments[0]); const root = Pattern.getLiteral(segments[0]);
(0, assert_1.default)(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`);
pattern = new internal_path_1.Path(segments).toString().trim(); pattern = new internal_path_1.Path(segments).toString().trim();
if (patternOrNegate) { if (patternOrNegate) {
pattern = `!${pattern}`; pattern = `!${pattern}`;
@@ -9948,13 +9903,13 @@ class Pattern {
*/ */
static fixupPattern(pattern, homedir) { static fixupPattern(pattern, homedir) {
// Empty // Empty
(0, assert_1.default)(pattern, 'pattern cannot be empty'); assert_1.default(pattern, 'pattern cannot be empty');
// Must not contain `.` segment, unless first segment // Must not contain `.` segment, unless first segment
// Must not contain `..` segment // Must not contain `..` segment
const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x)); const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x));
(0, assert_1.default)(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`);
// Must not contain globs in root, e.g. Windows UNC path \\foo\b*r // Must not contain globs in root, e.g. Windows UNC path \\foo\b*r
(0, assert_1.default)(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`);
// Normalize slashes // Normalize slashes
pattern = pathHelper.normalizeSeparators(pattern); pattern = pathHelper.normalizeSeparators(pattern);
// Replace leading `.` segment // Replace leading `.` segment
@@ -9964,8 +9919,8 @@ class Pattern {
// Replace leading `~` segment // Replace leading `~` segment
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) { else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
homedir = homedir || os.homedir(); homedir = homedir || os.homedir();
(0, assert_1.default)(homedir, 'Unable to determine HOME directory'); assert_1.default(homedir, 'Unable to determine HOME directory');
(0, assert_1.default)(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`);
pattern = Pattern.globEscape(homedir) + pattern.substr(1); pattern = Pattern.globEscape(homedir) + pattern.substr(1);
} }
// Replace relative drive root, e.g. pattern is C: or C:foo // Replace relative drive root, e.g. pattern is C: or C:foo
@@ -125772,7 +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["IncludeGitDirectory"] = "include-git-directory";
})(Inputs = exports.Inputs || (exports.Inputs = {})); })(Inputs = exports.Inputs || (exports.Inputs = {}));
@@ -125856,7 +125811,7 @@ 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 includeGitDirectory = core.getBooleanInput(constants_1.Inputs.IncludeGitDirectory);
const inputs = { const inputs = {
name, name,
pattern, pattern,
@@ -125864,7 +125819,7 @@ function getInputs() {
deleteMerged, deleteMerged,
retentionDays: 0, retentionDays: 0,
compressionLevel: 6, compressionLevel: 6,
includeHiddenFiles includeGitDirectory
}; };
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
if (retentionDaysStr) { if (retentionDaysStr) {
@@ -125980,7 +125935,9 @@ 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, inputs.includeHiddenFiles); const searchResult = yield (0, search_1.findFilesToUpload)(tmpDir, {
includeGitDirectory: inputs.includeGitDirectory
});
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) {
@@ -126047,12 +126004,11 @@ 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(includeHiddenFiles) { function getDefaultGlobOptions() {
return { return {
followSymbolicLinks: true, followSymbolicLinks: true,
implicitDescendants: true, implicitDescendants: true,
omitBrokenSymbolicLinks: true, omitBrokenSymbolicLinks: true
excludeHiddenFiles: !includeHiddenFiles
}; };
} }
/** /**
@@ -126106,10 +126062,10 @@ function getMultiPathLCA(searchPaths) {
} }
return path.join(...commonPaths); return path.join(...commonPaths);
} }
function findFilesToUpload(searchPath, includeHiddenFiles) { function findFilesToUpload(searchPath, searchOptions) {
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, getDefaultGlobOptions(includeHiddenFiles || false)); const globber = yield glob.create(searchPath, getDefaultGlobOptions());
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
@@ -126125,6 +126081,10 @@ function findFilesToUpload(searchPath, includeHiddenFiles) {
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead // isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
if (!fileStats.isDirectory()) { if (!fileStats.isDirectory()) {
(0, core_1.debug)(`File:${searchResult} was found using the provided searchPath`); (0, core_1.debug)(`File:${searchResult} was found using the provided searchPath`);
if (!(searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.includeGitDirectory) && inGitDirectory(searchResult)) {
(0, core_1.debug)(`Ignoring ${searchResult} because it is in the .git directory`);
continue;
}
searchResults.push(searchResult); searchResults.push(searchResult);
// detect any files that would be overwritten because of case insensitivity // detect any files that would be overwritten because of case insensitivity
if (set.has(searchResult.toLowerCase())) { if (set.has(searchResult.toLowerCase())) {
@@ -126166,6 +126126,16 @@ function findFilesToUpload(searchPath, includeHiddenFiles) {
}); });
} }
exports.findFilesToUpload = findFilesToUpload; exports.findFilesToUpload = findFilesToUpload;
function inGitDirectory(filePath) {
// The .git directory is a directory, so we need to check if the file path is a directory
// and if it is a .git directory
for (const part of filePath.split(path.sep)) {
if (part === '.git') {
return true;
}
}
return false;
}
/***/ }), /***/ }),

174
dist/upload/index.js vendored
View File

@@ -8881,18 +8881,16 @@ exports.create = create;
* Computes the sha256 hash of a glob * Computes the sha256 hash of a glob
* *
* @param patterns Patterns separated by newlines * @param patterns Patterns separated by newlines
* @param currentWorkspace Workspace used when matching files
* @param options Glob options * @param options Glob options
* @param verbose Enables verbose logging
*/ */
function hashFiles(patterns, currentWorkspace = '', options, verbose = false) { function hashFiles(patterns, options, verbose = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let followSymbolicLinks = true; let followSymbolicLinks = true;
if (options && typeof options.followSymbolicLinks === 'boolean') { if (options && typeof options.followSymbolicLinks === 'boolean') {
followSymbolicLinks = options.followSymbolicLinks; followSymbolicLinks = options.followSymbolicLinks;
} }
const globber = yield create(patterns, { followSymbolicLinks }); const globber = yield create(patterns, { followSymbolicLinks });
return (0, internal_hash_files_1.hashFiles)(globber, currentWorkspace, verbose); return internal_hash_files_1.hashFiles(globber, verbose);
}); });
} }
exports.hashFiles = hashFiles; exports.hashFiles = hashFiles;
@@ -8907,11 +8905,7 @@ exports.hashFiles = hashFiles;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8924,7 +8918,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -8939,8 +8933,7 @@ function getOptions(copy) {
followSymbolicLinks: true, followSymbolicLinks: true,
implicitDescendants: true, implicitDescendants: true,
matchDirectories: true, matchDirectories: true,
omitBrokenSymbolicLinks: true, omitBrokenSymbolicLinks: true
excludeHiddenFiles: false
}; };
if (copy) { if (copy) {
if (typeof copy.followSymbolicLinks === 'boolean') { if (typeof copy.followSymbolicLinks === 'boolean') {
@@ -8959,10 +8952,6 @@ function getOptions(copy) {
result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks; result.omitBrokenSymbolicLinks = copy.omitBrokenSymbolicLinks;
core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`); core.debug(`omitBrokenSymbolicLinks '${result.omitBrokenSymbolicLinks}'`);
} }
if (typeof copy.excludeHiddenFiles === 'boolean') {
result.excludeHiddenFiles = copy.excludeHiddenFiles;
core.debug(`excludeHiddenFiles '${result.excludeHiddenFiles}'`);
}
} }
return result; return result;
} }
@@ -8978,11 +8967,7 @@ exports.getOptions = getOptions;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -8995,7 +8980,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9049,21 +9034,19 @@ class DefaultGlobber {
return this.searchPaths.slice(); return this.searchPaths.slice();
} }
glob() { glob() {
var _a, e_1, _b, _c; var e_1, _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const result = []; const result = [];
try { try {
for (var _d = true, _e = __asyncValues(this.globGenerator()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { for (var _b = __asyncValues(this.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
_c = _f.value; const itemPath = _c.value;
_d = false;
const itemPath = _c;
result.push(itemPath); result.push(itemPath);
} }
} }
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
@@ -9121,10 +9104,6 @@ class DefaultGlobber {
if (!stats) { if (!stats) {
continue; continue;
} }
// Hidden file or directory?
if (options.excludeHiddenFiles && path.basename(item.path).match(/^\./)) {
continue;
}
// Directory // Directory
if (stats.isDirectory()) { if (stats.isDirectory()) {
// Matched // Matched
@@ -9230,11 +9209,7 @@ exports.DefaultGlobber = DefaultGlobber;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9247,7 +9222,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9275,22 +9250,18 @@ const fs = __importStar(__nccwpck_require__(57147));
const stream = __importStar(__nccwpck_require__(12781)); const stream = __importStar(__nccwpck_require__(12781));
const util = __importStar(__nccwpck_require__(73837)); const util = __importStar(__nccwpck_require__(73837));
const path = __importStar(__nccwpck_require__(71017)); const path = __importStar(__nccwpck_require__(71017));
function hashFiles(globber, currentWorkspace, verbose = false) { function hashFiles(globber, verbose = false) {
var _a, e_1, _b, _c; var e_1, _a;
var _d; var _b;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const writeDelegate = verbose ? core.info : core.debug; const writeDelegate = verbose ? core.info : core.debug;
let hasMatch = false; let hasMatch = false;
const githubWorkspace = currentWorkspace const githubWorkspace = (_b = process.env['GITHUB_WORKSPACE']) !== null && _b !== void 0 ? _b : process.cwd();
? currentWorkspace
: (_d = process.env['GITHUB_WORKSPACE']) !== null && _d !== void 0 ? _d : process.cwd();
const result = crypto.createHash('sha256'); const result = crypto.createHash('sha256');
let count = 0; let count = 0;
try { try {
for (var _e = true, _f = __asyncValues(globber.globGenerator()), _g; _g = yield _f.next(), _a = _g.done, !_a; _e = true) { for (var _c = __asyncValues(globber.globGenerator()), _d; _d = yield _c.next(), !_d.done;) {
_c = _g.value; const file = _d.value;
_e = false;
const file = _c;
writeDelegate(file); writeDelegate(file);
if (!file.startsWith(`${githubWorkspace}${path.sep}`)) { if (!file.startsWith(`${githubWorkspace}${path.sep}`)) {
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
@@ -9313,7 +9284,7 @@ function hashFiles(globber, currentWorkspace, verbose = false) {
catch (e_1_1) { e_1 = { error: e_1_1 }; } catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally { finally {
try { try {
if (!_e && !_a && (_b = _f.return)) yield _b.call(_f); if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
} }
finally { if (e_1) throw e_1.error; } finally { if (e_1) throw e_1.error; }
} }
@@ -9353,7 +9324,7 @@ var MatchKind;
MatchKind[MatchKind["File"] = 2] = "File"; MatchKind[MatchKind["File"] = 2] = "File";
/** Matched */ /** Matched */
MatchKind[MatchKind["All"] = 3] = "All"; MatchKind[MatchKind["All"] = 3] = "All";
})(MatchKind || (exports.MatchKind = MatchKind = {})); })(MatchKind = exports.MatchKind || (exports.MatchKind = {}));
//# sourceMappingURL=internal-match-kind.js.map //# sourceMappingURL=internal-match-kind.js.map
/***/ }), /***/ }),
@@ -9365,11 +9336,7 @@ var MatchKind;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9382,7 +9349,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9432,8 +9399,8 @@ exports.dirname = dirname;
* or `C:` are expanded based on the current working directory. * or `C:` are expanded based on the current working directory.
*/ */
function ensureAbsoluteRoot(root, itemPath) { function ensureAbsoluteRoot(root, itemPath) {
(0, assert_1.default)(root, `ensureAbsoluteRoot parameter 'root' must not be empty`); assert_1.default(root, `ensureAbsoluteRoot parameter 'root' must not be empty`);
(0, assert_1.default)(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `ensureAbsoluteRoot parameter 'itemPath' must not be empty`);
// Already rooted // Already rooted
if (hasAbsoluteRoot(itemPath)) { if (hasAbsoluteRoot(itemPath)) {
return itemPath; return itemPath;
@@ -9443,7 +9410,7 @@ function ensureAbsoluteRoot(root, itemPath) {
// Check for itemPath like C: or C:foo // Check for itemPath like C: or C:foo
if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) { if (itemPath.match(/^[A-Z]:[^\\/]|^[A-Z]:$/i)) {
let cwd = process.cwd(); let cwd = process.cwd();
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
// Drive letter matches cwd? Expand to cwd // Drive letter matches cwd? Expand to cwd
if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) { if (itemPath[0].toUpperCase() === cwd[0].toUpperCase()) {
// Drive only, e.g. C: // Drive only, e.g. C:
@@ -9468,11 +9435,11 @@ function ensureAbsoluteRoot(root, itemPath) {
// Check for itemPath like \ or \foo // Check for itemPath like \ or \foo
else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) { else if (normalizeSeparators(itemPath).match(/^\\$|^\\[^\\]/)) {
const cwd = process.cwd(); const cwd = process.cwd();
(0, assert_1.default)(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`); assert_1.default(cwd.match(/^[A-Z]:\\/i), `Expected current directory to start with an absolute drive root. Actual '${cwd}'`);
return `${cwd[0]}:\\${itemPath.substr(1)}`; return `${cwd[0]}:\\${itemPath.substr(1)}`;
} }
} }
(0, assert_1.default)(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`); assert_1.default(hasAbsoluteRoot(root), `ensureAbsoluteRoot parameter 'root' must have an absolute root`);
// Otherwise ensure root ends with a separator // Otherwise ensure root ends with a separator
if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) { if (root.endsWith('/') || (IS_WINDOWS && root.endsWith('\\'))) {
// Intentionally empty // Intentionally empty
@@ -9489,7 +9456,7 @@ exports.ensureAbsoluteRoot = ensureAbsoluteRoot;
* `\\hello\share` and `C:\hello` (and using alternate separator). * `\\hello\share` and `C:\hello` (and using alternate separator).
*/ */
function hasAbsoluteRoot(itemPath) { function hasAbsoluteRoot(itemPath) {
(0, assert_1.default)(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `hasAbsoluteRoot parameter 'itemPath' must not be empty`);
// Normalize separators // Normalize separators
itemPath = normalizeSeparators(itemPath); itemPath = normalizeSeparators(itemPath);
// Windows // Windows
@@ -9506,7 +9473,7 @@ exports.hasAbsoluteRoot = hasAbsoluteRoot;
* `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator). * `\`, `\hello`, `\\hello\share`, `C:`, and `C:\hello` (and using alternate separator).
*/ */
function hasRoot(itemPath) { function hasRoot(itemPath) {
(0, assert_1.default)(itemPath, `isRooted parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `isRooted parameter 'itemPath' must not be empty`);
// Normalize separators // Normalize separators
itemPath = normalizeSeparators(itemPath); itemPath = normalizeSeparators(itemPath);
// Windows // Windows
@@ -9574,11 +9541,7 @@ exports.safeTrimTrailingSeparator = safeTrimTrailingSeparator;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9591,7 +9554,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9616,7 +9579,7 @@ class Path {
this.segments = []; this.segments = [];
// String // String
if (typeof itemPath === 'string') { if (typeof itemPath === 'string') {
(0, assert_1.default)(itemPath, `Parameter 'itemPath' must not be empty`); assert_1.default(itemPath, `Parameter 'itemPath' must not be empty`);
// Normalize slashes and trim unnecessary trailing slash // Normalize slashes and trim unnecessary trailing slash
itemPath = pathHelper.safeTrimTrailingSeparator(itemPath); itemPath = pathHelper.safeTrimTrailingSeparator(itemPath);
// Not rooted // Not rooted
@@ -9643,24 +9606,24 @@ class Path {
// Array // Array
else { else {
// Must not be empty // Must not be empty
(0, assert_1.default)(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`); assert_1.default(itemPath.length > 0, `Parameter 'itemPath' must not be an empty array`);
// Each segment // Each segment
for (let i = 0; i < itemPath.length; i++) { for (let i = 0; i < itemPath.length; i++) {
let segment = itemPath[i]; let segment = itemPath[i];
// Must not be empty // Must not be empty
(0, assert_1.default)(segment, `Parameter 'itemPath' must not contain any empty segments`); assert_1.default(segment, `Parameter 'itemPath' must not contain any empty segments`);
// Normalize slashes // Normalize slashes
segment = pathHelper.normalizeSeparators(itemPath[i]); segment = pathHelper.normalizeSeparators(itemPath[i]);
// Root segment // Root segment
if (i === 0 && pathHelper.hasRoot(segment)) { if (i === 0 && pathHelper.hasRoot(segment)) {
segment = pathHelper.safeTrimTrailingSeparator(segment); segment = pathHelper.safeTrimTrailingSeparator(segment);
(0, assert_1.default)(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`); assert_1.default(segment === pathHelper.dirname(segment), `Parameter 'itemPath' root segment contains information for multiple segments`);
this.segments.push(segment); this.segments.push(segment);
} }
// All other segments // All other segments
else { else {
// Must not contain slash // Must not contain slash
(0, assert_1.default)(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`); assert_1.default(!segment.includes(path.sep), `Parameter 'itemPath' contains unexpected path separators`);
this.segments.push(segment); this.segments.push(segment);
} }
} }
@@ -9698,11 +9661,7 @@ exports.Path = Path;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9715,7 +9674,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9803,11 +9762,7 @@ exports.partialMatch = partialMatch;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k); Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) { }) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k; if (k2 === undefined) k2 = k;
o[k2] = m[k]; o[k2] = m[k];
@@ -9820,7 +9775,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod; if (mod && mod.__esModule) return mod;
var result = {}; var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
@@ -9852,9 +9807,9 @@ class Pattern {
else { else {
// Convert to pattern // Convert to pattern
segments = segments || []; segments = segments || [];
(0, assert_1.default)(segments.length, `Parameter 'segments' must not empty`); assert_1.default(segments.length, `Parameter 'segments' must not empty`);
const root = Pattern.getLiteral(segments[0]); const root = Pattern.getLiteral(segments[0]);
(0, assert_1.default)(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`); assert_1.default(root && pathHelper.hasAbsoluteRoot(root), `Parameter 'segments' first element must be a root path`);
pattern = new internal_path_1.Path(segments).toString().trim(); pattern = new internal_path_1.Path(segments).toString().trim();
if (patternOrNegate) { if (patternOrNegate) {
pattern = `!${pattern}`; pattern = `!${pattern}`;
@@ -9948,13 +9903,13 @@ class Pattern {
*/ */
static fixupPattern(pattern, homedir) { static fixupPattern(pattern, homedir) {
// Empty // Empty
(0, assert_1.default)(pattern, 'pattern cannot be empty'); assert_1.default(pattern, 'pattern cannot be empty');
// Must not contain `.` segment, unless first segment // Must not contain `.` segment, unless first segment
// Must not contain `..` segment // Must not contain `..` segment
const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x)); const literalSegments = new internal_path_1.Path(pattern).segments.map(x => Pattern.getLiteral(x));
(0, assert_1.default)(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`); assert_1.default(literalSegments.every((x, i) => (x !== '.' || i === 0) && x !== '..'), `Invalid pattern '${pattern}'. Relative pathing '.' and '..' is not allowed.`);
// Must not contain globs in root, e.g. Windows UNC path \\foo\b*r // Must not contain globs in root, e.g. Windows UNC path \\foo\b*r
(0, assert_1.default)(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`); assert_1.default(!pathHelper.hasRoot(pattern) || literalSegments[0], `Invalid pattern '${pattern}'. Root segment must not contain globs.`);
// Normalize slashes // Normalize slashes
pattern = pathHelper.normalizeSeparators(pattern); pattern = pathHelper.normalizeSeparators(pattern);
// Replace leading `.` segment // Replace leading `.` segment
@@ -9964,8 +9919,8 @@ class Pattern {
// Replace leading `~` segment // Replace leading `~` segment
else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) { else if (pattern === '~' || pattern.startsWith(`~${path.sep}`)) {
homedir = homedir || os.homedir(); homedir = homedir || os.homedir();
(0, assert_1.default)(homedir, 'Unable to determine HOME directory'); assert_1.default(homedir, 'Unable to determine HOME directory');
(0, assert_1.default)(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`);
pattern = Pattern.globEscape(homedir) + pattern.substr(1); pattern = Pattern.globEscape(homedir) + pattern.substr(1);
} }
// Replace relative drive root, e.g. pattern is C: or C:foo // Replace relative drive root, e.g. pattern is C: or C:foo
@@ -125802,12 +125757,11 @@ 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(includeHiddenFiles) { function getDefaultGlobOptions() {
return { return {
followSymbolicLinks: true, followSymbolicLinks: true,
implicitDescendants: true, implicitDescendants: true,
omitBrokenSymbolicLinks: true, omitBrokenSymbolicLinks: true
excludeHiddenFiles: !includeHiddenFiles
}; };
} }
/** /**
@@ -125861,10 +125815,10 @@ function getMultiPathLCA(searchPaths) {
} }
return path.join(...commonPaths); return path.join(...commonPaths);
} }
function findFilesToUpload(searchPath, includeHiddenFiles) { function findFilesToUpload(searchPath, searchOptions) {
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, getDefaultGlobOptions(includeHiddenFiles || false)); const globber = yield glob.create(searchPath, getDefaultGlobOptions());
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
@@ -125880,6 +125834,10 @@ function findFilesToUpload(searchPath, includeHiddenFiles) {
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead // isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
if (!fileStats.isDirectory()) { if (!fileStats.isDirectory()) {
(0, core_1.debug)(`File:${searchResult} was found using the provided searchPath`); (0, core_1.debug)(`File:${searchResult} was found using the provided searchPath`);
if (!(searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.includeGitDirectory) && inGitDirectory(searchResult)) {
(0, core_1.debug)(`Ignoring ${searchResult} because it is in the .git directory`);
continue;
}
searchResults.push(searchResult); searchResults.push(searchResult);
// detect any files that would be overwritten because of case insensitivity // detect any files that would be overwritten because of case insensitivity
if (set.has(searchResult.toLowerCase())) { if (set.has(searchResult.toLowerCase())) {
@@ -125921,6 +125879,16 @@ function findFilesToUpload(searchPath, includeHiddenFiles) {
}); });
} }
exports.findFilesToUpload = findFilesToUpload; exports.findFilesToUpload = findFilesToUpload;
function inGitDirectory(filePath) {
// The .git directory is a directory, so we need to check if the file path is a directory
// and if it is a .git directory
for (const part of filePath.split(path.sep)) {
if (part === '.git') {
return true;
}
}
return false;
}
/***/ }), /***/ }),
@@ -126002,7 +125970,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["IncludeGitDirectory"] = "include-git-directory";
})(Inputs = exports.Inputs || (exports.Inputs = {})); })(Inputs = exports.Inputs || (exports.Inputs = {}));
var NoFileOptions; var NoFileOptions;
(function (NoFileOptions) { (function (NoFileOptions) {
@@ -126100,7 +126068,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 includeGitDirectory = core.getBooleanInput(constants_1.Inputs.IncludeGitDirectory);
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) {
@@ -126111,7 +126079,7 @@ function getInputs() {
searchPath: path, searchPath: path,
ifNoFilesFound: noFileBehavior, ifNoFilesFound: noFileBehavior,
overwrite: overwrite, overwrite: overwrite,
includeHiddenFiles: includeHiddenFiles includeGitDirectory: includeGitDirectory
}; };
const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays); const retentionDaysStr = core.getInput(constants_1.Inputs.RetentionDays);
if (retentionDaysStr) { if (retentionDaysStr) {
@@ -126200,7 +126168,9 @@ 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, inputs.includeHiddenFiles); const searchResult = yield (0, search_1.findFilesToUpload)(inputs.searchPath, {
includeGitDirectory: inputs.includeGitDirectory
});
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) {

View File

@@ -4,7 +4,6 @@
- [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`.
@@ -209,26 +208,25 @@ jobs:
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 ## `.git` Directory
By default, hidden files are ignored by this action to avoid unintentionally uploading sensitive By default, files in the `.git` directory are ignored to avoid unintentionally uploading
information. credentials.
In versions of this action before v4.4.0, these hidden files were included by default. In versions of this action before `v4.4.0`, files in the `.git` directory were included by default.
If this directory is required, ensure credentials are not saved in `.git/config` and then
If you need to upload hidden files, you can use the `include-hidden-files` input. enable the `include-git-directory` input.
```yaml ```yaml
jobs: jobs:
upload: upload:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create a Hidden File - uses: actions/checkout@v4
run: echo "hello from a hidden file" > .hidden-file.txt
- name: Upload Artifact - name: Upload Artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
path: .hidden-file.txt path: .
``` ```
@@ -237,12 +235,13 @@ jobs:
upload: upload:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Create a Hidden File - uses: actions/checkout@v4
run: echo "hello from a hidden file" > .hidden-file.txt + with:
+ persist-credentials: false
- 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:
path: .hidden-file.txt path: .
+ include-hidden-files: true + include-git-directory: true
``` ```

View File

@@ -5,6 +5,7 @@ Merge multiple [Actions Artifacts](https://docs.github.com/en/actions/using-work
- [`@actions/upload-artifact/merge`](#actionsupload-artifactmerge) - [`@actions/upload-artifact/merge`](#actionsupload-artifactmerge)
- [Usage](#usage) - [Usage](#usage)
- [Inputs](#inputs) - [Inputs](#inputs)
- [Uploading the `.git` directory](#uploading-the-git-directory)
- [Outputs](#outputs) - [Outputs](#outputs)
- [Examples](#examples) - [Examples](#examples)
- [Combining all artifacts in a workflow run](#combining-all-artifacts-in-a-workflow-run) - [Combining all artifacts in a workflow run](#combining-all-artifacts-in-a-workflow-run)
@@ -59,6 +60,44 @@ For most cases, this may not be the most efficient solution. See [the migration
compression-level: compression-level:
``` ```
#### Uploading the `.git` directory
By default, files in a `.git` directory are ignored in the merged artifact.
This is intended to prevent accidentally uploading Git credentials into an artifact that could then
be extracted.
If files in the `.git` directory are needed, ensure that `actions/checkout` is being used with
`persist-credentials: false`.
```yaml
jobs:
upload:
runs-on: ubuntu-latest
strategy:
matrix:
foo: [a, b, c]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # Ensure credentials are not saved in `.git/config`
- name: Upload
uses: actions/upload-artifact@v4
with:
name: my-artifact-${{ matrix.foo }}
path: .
include-git-directory: true
merge:
runs-on: ubuntu-latest
steps:
- uses: actions/upload-artifact/merge@v4
with:
include-git-directory: true
```
### Outputs ### Outputs
| Name | Description | Example | | Name | Description | Example |

View File

@@ -36,10 +36,8 @@ 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: include-git-directory:
description: > description: 'Include files in the .git directory in the merged artifact.'
If true, hidden files will be included in the merged artifact.
If false, hidden files will be excluded from the merged artifact.
default: 'false' default: 'false'
outputs: outputs:

22
package-lock.json generated
View File

@@ -1,18 +1,18 @@
{ {
"name": "upload-artifact", "name": "upload-artifact",
"version": "4.4.0", "version": "4.3.6",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "upload-artifact", "name": "upload-artifact",
"version": "4.4.0", "version": "4.3.6",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/artifact": "2.1.8", "@actions/artifact": "2.1.8",
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@actions/glob": "^0.5.0", "@actions/glob": "^0.3.0",
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"minimatch": "^9.0.3" "minimatch": "^9.0.3"
}, },
@@ -191,11 +191,11 @@
} }
}, },
"node_modules/@actions/glob": { "node_modules/@actions/glob": {
"version": "0.5.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz",
"integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==",
"dependencies": { "dependencies": {
"@actions/core": "^1.9.1", "@actions/core": "^1.2.6",
"minimatch": "^3.0.4" "minimatch": "^3.0.4"
} }
}, },
@@ -8036,11 +8036,11 @@
} }
}, },
"@actions/glob": { "@actions/glob": {
"version": "0.5.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz", "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz",
"integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==", "integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==",
"requires": { "requires": {
"@actions/core": "^1.9.1", "@actions/core": "^1.2.6",
"minimatch": "^3.0.4" "minimatch": "^3.0.4"
}, },
"dependencies": { "dependencies": {

View File

@@ -32,7 +32,7 @@
"@actions/artifact": "2.1.8", "@actions/artifact": "2.1.8",
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",
"@actions/github": "^6.0.0", "@actions/github": "^6.0.0",
"@actions/glob": "^0.5.0", "@actions/glob": "^0.3.0",
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"minimatch": "^9.0.3" "minimatch": "^9.0.3"
}, },

View File

@@ -6,5 +6,5 @@ export enum Inputs {
RetentionDays = 'retention-days', RetentionDays = 'retention-days',
CompressionLevel = 'compression-level', CompressionLevel = 'compression-level',
DeleteMerged = 'delete-merged', DeleteMerged = 'delete-merged',
IncludeHiddenFiles = 'include-hidden-files' IncludeGitDirectory = 'include-git-directory'
} }

View File

@@ -10,7 +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 includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
const inputs = { const inputs = {
name, name,
@@ -19,7 +19,7 @@ export function getInputs(): MergeInputs {
deleteMerged, deleteMerged,
retentionDays: 0, retentionDays: 0,
compressionLevel: 6, compressionLevel: 6,
includeHiddenFiles includeGitDirectory
} as MergeInputs } as MergeInputs
const retentionDaysStr = core.getInput(Inputs.RetentionDays) const retentionDaysStr = core.getInput(Inputs.RetentionDays)

View File

@@ -62,10 +62,9 @@ export async function run(): Promise<void> {
options.compressionLevel = inputs.compressionLevel options.compressionLevel = inputs.compressionLevel
} }
const searchResult = await findFilesToUpload( const searchResult = await findFilesToUpload(tmpDir, {
tmpDir, includeGitDirectory: inputs.includeGitDirectory
inputs.includeHiddenFiles })
)
await uploadArtifact( await uploadArtifact(
inputs.name, inputs.name,

View File

@@ -32,7 +32,7 @@ export interface MergeInputs {
separateDirectories: boolean separateDirectories: boolean
/** /**
* Whether or not to include hidden files in the artifact * Include files in the `.git` directory in the artifact
*/ */
includeHiddenFiles: boolean includeGitDirectory: boolean
} }

View File

@@ -11,12 +11,11 @@ export interface SearchResult {
rootDirectory: string rootDirectory: string
} }
function getDefaultGlobOptions(includeHiddenFiles: boolean): glob.GlobOptions { function getDefaultGlobOptions(): glob.GlobOptions {
return { return {
followSymbolicLinks: true, followSymbolicLinks: true,
implicitDescendants: true, implicitDescendants: true,
omitBrokenSymbolicLinks: true, omitBrokenSymbolicLinks: true
excludeHiddenFiles: !includeHiddenFiles
} }
} }
@@ -79,15 +78,21 @@ function getMultiPathLCA(searchPaths: string[]): string {
return path.join(...commonPaths) return path.join(...commonPaths)
} }
export interface SearchOptions {
/**
* Indicates whether files in the .git directory should be included in the artifact
*
* @default false
*/
includeGitDirectory: boolean
}
export async function findFilesToUpload( export async function findFilesToUpload(
searchPath: string, searchPath: string,
includeHiddenFiles?: boolean searchOptions?: SearchOptions
): Promise<SearchResult> { ): Promise<SearchResult> {
const searchResults: string[] = [] const searchResults: string[] = []
const globber = await glob.create( const globber = await glob.create(searchPath, getDefaultGlobOptions())
searchPath,
getDefaultGlobOptions(includeHiddenFiles || false)
)
const rawSearchResults: string[] = await globber.glob() const rawSearchResults: string[] = await globber.glob()
/* /*
@@ -105,6 +110,12 @@ export async function findFilesToUpload(
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead // isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
if (!fileStats.isDirectory()) { if (!fileStats.isDirectory()) {
debug(`File:${searchResult} was found using the provided searchPath`) debug(`File:${searchResult} was found using the provided searchPath`)
if (!searchOptions?.includeGitDirectory && inGitDirectory(searchResult)) {
debug(`Ignoring ${searchResult} because it is in the .git directory`)
continue
}
searchResults.push(searchResult) searchResults.push(searchResult)
// detect any files that would be overwritten because of case insensitivity // detect any files that would be overwritten because of case insensitivity
@@ -156,3 +167,15 @@ export async function findFilesToUpload(
rootDirectory: searchPaths[0] rootDirectory: searchPaths[0]
} }
} }
function inGitDirectory(filePath: string): boolean {
// The .git directory is a directory, so we need to check if the file path is a directory
// and if it is a .git directory
for (const part of filePath.split(path.sep)) {
if (part === '.git') {
return true
}
}
return false
}

View File

@@ -6,7 +6,7 @@ export enum Inputs {
RetentionDays = 'retention-days', RetentionDays = 'retention-days',
CompressionLevel = 'compression-level', CompressionLevel = 'compression-level',
Overwrite = 'overwrite', Overwrite = 'overwrite',
IncludeHiddenFiles = 'include-hidden-files' IncludeGitDirectory = 'include-git-directory'
} }
export enum NoFileOptions { export enum NoFileOptions {

View File

@@ -9,7 +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 includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound) const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound] const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
@@ -29,7 +29,7 @@ export function getInputs(): UploadInputs {
searchPath: path, searchPath: path,
ifNoFilesFound: noFileBehavior, ifNoFilesFound: noFileBehavior,
overwrite: overwrite, overwrite: overwrite,
includeHiddenFiles: includeHiddenFiles includeGitDirectory: includeGitDirectory
} as UploadInputs } as UploadInputs
const retentionDaysStr = core.getInput(Inputs.RetentionDays) const retentionDaysStr = core.getInput(Inputs.RetentionDays)

View File

@@ -24,10 +24,9 @@ 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( const searchResult = await findFilesToUpload(inputs.searchPath, {
inputs.searchPath, includeGitDirectory: inputs.includeGitDirectory
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) {

View File

@@ -32,7 +32,7 @@ export interface UploadInputs {
overwrite: boolean overwrite: boolean
/** /**
* Whether or not to include hidden files in the artifact * Include files in the `.git` directory in the artifact
*/ */
includeHiddenFiles: boolean includeGitDirectory: boolean
} }