Compare commits

..

24 Commits

Author SHA1 Message Date
b4b15b8c7c Merge pull request #632 from actions/joshmgross/undo-dependency-changes
Undo indirect dependency updates from #627
2024-10-09 13:16:31 -04:00
92b01ebffa Undo indirect dependency updates from #627 2024-10-09 12:35:22 -04:00
84480863f2 Merge pull request #627 from actions/robherley/v4.4.2
Bump `@actions/artifact` to 2.1.11
2024-10-08 14:15:05 -04:00
b1d4642b69 add explicit relative and absolute symlinks to workflow 2024-10-08 13:39:45 -04:00
d50e66084c bump version 2024-10-08 13:35:54 -04:00
aabe6f8050 build with @actions/artifact v2.1.11 2024-10-08 12:46:18 -04:00
604373da63 Merge pull request #625 from actions/robherley/artifact-2.1.10
Update @actions/artifact to latest version, includes symlink and timeout fixes
2024-10-07 11:46:25 -04:00
0150148bdf paste right core version 2024-10-07 09:57:16 -04:00
a009b25faa update licenses 2024-10-07 09:55:37 -04:00
9f6f6f402e update @actions/core and @actions/artifact to latest versions 2024-10-07 09:45:59 -04:00
3eadd8b791 Merge pull request #621 from actions/Jcambass-patch-1
Add workflow file for publishing releases to immutable action package
2024-09-26 08:20:21 +02:00
aeba9f7961 Add workflow file for publishing releases to immutable action package
This workflow file publishes new action releases to the immutable action package of the same name as this repo.

This is part of the Immutable Actions project which is not yet fully released to the public. First party actions like this one are part of our initial testing of this feature.
2024-09-24 15:53:26 +02:00
b18b1d32f3 Merge pull request #607 from actions/joshmgross/hidden-files-readme
Add a section about hidden files
2024-09-02 10:39:50 -04:00
d7c12077c4 Add a section about hidden files 2024-09-02 10:30:03 -04:00
50769540e7 Merge pull request #598 from actions/joshmgross/exclude-hidden-files
Exclude hidden files by default
2024-08-29 10:38:39 -04:00
d52396ac5d Add a warning about enabling include-hidden-files 2024-08-15 19:45:59 -04:00
710f362075 Remove "merged" from include-hidden-files input description 2024-08-15 19:39:39 -04:00
3b315f26f6 npm run release again 🙂 2024-08-15 17:36:20 -04:00
3be2180eb7 Remove another trailing comma 2024-08-15 17:35:00 -04:00
453e8d0a40 Update glob license 2024-08-15 17:31:21 -04:00
0a398c1480 npm run release 2024-08-15 17:30:44 -04:00
a0c40cf602 Update to latest @actions/glob and fix tests 2024-08-15 17:26:43 -04:00
acb59e4776 lint 2024-08-15 16:31:57 -04:00
cb6558bb10 Exclude hidden files by default 2024-08-15 16:22:09 -04:00
24 changed files with 3423 additions and 525 deletions

View File

@ -0,0 +1,20 @@
name: 'Publish Immutable Action Version'
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- name: Checking out
uses: actions/checkout@v4
- name: Publish
id: publish
uses: actions/publish-immutable-action@0.0.3

View File

@ -46,14 +46,19 @@ jobs:
- name: Test
run: npm run test
# Test end-to-end by uploading two artifacts and then downloading them
# Test end-to-end by uploading a few artifacts and then downloading them
- name: Create artifact files
run: |
mkdir -p path/to/dir-1
mkdir -p path/to/dir-2
mkdir -p path/to/dir-3
mkdir -p symlink/
echo "Lorem ipsum dolor sit amet" > path/to/dir-1/file1.txt
echo "Hello world from file #2" > path/to/dir-2/file2.txt
echo "Hello from a symlinked file" > symlink/original.txt
ln -s $(pwd)/symlink/original.txt symlink/abs.txt
ln -s original.txt symlink/rel.txt
shell: bash
# Upload a single file artifact
- name: 'Upload artifact #1'
@ -79,6 +84,14 @@ jobs:
path/to/dir-[23]/*
!path/to/dir-3/*.txt
- name: 'Upload symlinked artifact'
uses: ./
with:
name: 'Symlinked-Artifact-${{ matrix.runs-on }}'
path: |
symlink/abs.txt
symlink/rel.txt
# Download Artifact #1 and verify the correctness of the content
- name: 'Download artifact #1'
uses: actions/download-artifact@v4
@ -141,6 +154,34 @@ jobs:
}
shell: pwsh
- name: 'Download symlinked artifact'
uses: actions/download-artifact@v4
with:
name: 'Symlinked-Artifact-${{ matrix.runs-on }}'
path: from/symlink
- name: 'Verify symlinked artifact'
run: |
$abs = "from/symlink/abs.txt"
if(!(Test-Path -path $abs))
{
Write-Error "Expected file does not exist"
}
if(!((Get-Content $abs) -ceq "Hello from a symlinked file"))
{
Write-Error "File contents of downloaded artifact are incorrect"
}
$rel = "from/symlink/rel.txt"
if(!(Test-Path -path $rel))
{
Write-Error "Expected file does not exist"
}
if(!((Get-Content $rel) -ceq "Hello from a symlinked file"))
{
Write-Error "File contents of downloaded artifact are incorrect"
}
shell: pwsh
- name: 'Alter file 1 content'
run: |
echo "This file has changed" > path/to/dir-1/file1.txt

View File

@ -1,6 +1,6 @@
---
name: "@actions/artifact"
version: 2.1.8
version: 2.1.11
type: npm
summary:
homepage:

View File

@ -1,6 +1,6 @@
---
name: "@actions/core"
version: 1.10.1
version: 1.11.1
type: npm
summary:
homepage:

View File

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

View File

@ -16,7 +16,6 @@ See also [download-artifact](https://github.com/actions/download-artifact).
- [Breaking Changes](#breaking-changes)
- [Usage](#usage)
- [Inputs](#inputs)
- [Uploading the `.git` directory](#uploading-the-git-directory)
- [Outputs](#outputs)
- [Examples](#examples)
- [Upload an Individual File](#upload-an-individual-file)
@ -65,7 +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.
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, the `.git` directory is excluded by default.
4. With `v4.4` and later, hidden files are excluded by default.
For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
@ -109,30 +108,12 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
# Does not fail if the artifact does not exist.
# Optional. Default is 'false'
overwrite:
```
#### Uploading the `.git` directory
By default, files in a `.git` directory are ignored in the uploaded 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
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
# Whether to include hidden files in the provided path in the artifact
# The file contents of any hidden files in the path should be validated before
# enabled this to avoid uploading sensitive information.
# Optional. Default is 'false'
include-hidden-files:
```
### Outputs
@ -436,6 +417,28 @@ jobs:
overwrite: true
```
### Uploading Hidden Files
By default, hidden files are ignored by this action to avoid unintentionally uploading sensitive information.
If you need to upload hidden files, you can use the `include-hidden-files` input.
Any files that contain sensitive information that should not be in the uploaded artifact can be excluded
using the `path`:
```yaml
- uses: actions/upload-artifact@v4
with:
name: my-artifact
include-hidden-files: true
path: |
path/output/
!path/output/.production.env
```
Hidden files are defined as any file beginning with `.` or files within folders beginning with `.`.
On Windows, files and directories with the hidden attribute are not considered hidden files unless
they have the `.` prefix.
## Limitations
### Number of Artifacts

View File

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

View File

@ -40,8 +40,10 @@ inputs:
If false, the action will fail if an artifact for the given name already exists.
Does not fail if the artifact does not exist.
default: 'false'
include-git-directory:
description: 'Include files in the .git directory in the artifact.'
include-hidden-files:
description: >
If true, hidden files will be included in the artifact.
If false, hidden files will be excluded from the artifact.
default: 'false'
outputs:

1721
dist/merge/index.js vendored

File diff suppressed because it is too large Load Diff

1721
dist/upload/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@
- [Multiple uploads to the same named Artifact](#multiple-uploads-to-the-same-named-artifact)
- [Overwriting an Artifact](#overwriting-an-artifact)
- [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`.
@ -189,44 +190,45 @@ jobs:
- name: Create a File
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
- name: Upload Artifact
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v3
+ uses: actions/upload-artifact@v4
with:
- name: all-my-files
+ name: my-artifact-${{ matrix.runs-on }}
path: file-${{ matrix.runs-on }}.txt
+ merge:
+ runs-on: ubuntu-latest
+ needs: upload
+ steps:
+ - name: Merge Artifacts
+ uses: actions/upload-artifact/merge@v4
+ with:
+ name: all-my-files
+ pattern: my-artifact-*
+ merge:
+ runs-on: ubuntu-latest
+ needs: upload
+ steps:
+ - name: Merge Artifacts
+ uses: actions/upload-artifact/merge@v4
+ with:
+ name: all-my-files
+ 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).
## `.git` Directory
## Hidden Files
By default, files in the `.git` directory are ignored to avoid unintentionally uploading
credentials.
By default, hidden files are ignored by this action to avoid unintentionally uploading sensitive
information.
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
enable the `include-git-directory` input.
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:
- uses: actions/checkout@v4
- 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: .
path: .hidden-file.txt
```
@ -235,13 +237,12 @@ jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- 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: .
+ include-git-directory: true
path: .hidden-file.txt
+ include-hidden-files: true
```

View File

@ -5,7 +5,6 @@ Merge multiple [Actions Artifacts](https://docs.github.com/en/actions/using-work
- [`@actions/upload-artifact/merge`](#actionsupload-artifactmerge)
- [Usage](#usage)
- [Inputs](#inputs)
- [Uploading the `.git` directory](#uploading-the-git-directory)
- [Outputs](#outputs)
- [Examples](#examples)
- [Combining all artifacts in a workflow run](#combining-all-artifacts-in-a-workflow-run)
@ -60,44 +59,6 @@ For most cases, this may not be the most efficient solution. See [the migration
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
| Name | Description | Example |

View File

@ -36,8 +36,10 @@ inputs:
If true, the artifacts that were merged will be deleted.
If false, the artifacts will still exist.
default: 'false'
include-git-directory:
description: 'Include files in the .git directory in the merged artifact.'
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:

132
package-lock.json generated
View File

@ -1,18 +1,18 @@
{
"name": "upload-artifact",
"version": "4.3.6",
"version": "4.4.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "upload-artifact",
"version": "4.3.6",
"version": "4.4.3",
"license": "MIT",
"dependencies": {
"@actions/artifact": "2.1.8",
"@actions/core": "^1.10.1",
"@actions/artifact": "^2.1.11",
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@actions/glob": "^0.3.0",
"@actions/glob": "^0.5.0",
"@actions/io": "^1.1.2",
"minimatch": "^9.0.3"
},
@ -34,9 +34,9 @@
}
},
"node_modules/@actions/artifact": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-2.1.8.tgz",
"integrity": "sha512-kxgbllgF5f6mEdMeSW6WXlUbV1U77V9ECpA7LOYaY+Tm6RfXOm36EdXbpm+T9VPeaVqXK4QHLAgqay9GSyClgw==",
"version": "2.1.11",
"resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-2.1.11.tgz",
"integrity": "sha512-V/N/3yM3oLxozq2dpdGqbd/39UbDOR54bF25vYsvn3QZnyZERSzPjTAAwpGzdcwESye9G7vnuhPiKQACEuBQpg==",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
@ -48,7 +48,6 @@
"@octokit/request-error": "^5.0.0",
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
"archiver": "^7.0.1",
"crypto": "^1.0.1",
"jwt-decode": "^3.1.2",
"twirp-ts": "^2.5.0",
"unzip-stream": "^0.3.1"
@ -66,12 +65,22 @@
}
},
"node_modules/@actions/core": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
"integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
"license": "MIT",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"license": "MIT",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/github": {
@ -191,11 +200,11 @@
}
},
"node_modules/@actions/glob": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz",
"integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==",
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz",
"integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.9.1",
"minimatch": "^3.0.4"
}
},
@ -3229,12 +3238,6 @@
"which": "^2.0.1"
}
},
"node_modules/crypto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
"deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in."
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
@ -6101,12 +6104,13 @@
}
},
"node_modules/micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"dependencies": {
"braces": "^3.0.2",
"braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
@ -6463,9 +6467,10 @@
}
},
"node_modules/path-to-regexp": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
"integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==",
"license": "MIT"
},
"node_modules/path-type": {
"version": "4.0.0",
@ -7600,9 +7605,10 @@
"integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ=="
},
"node_modules/unzip-stream": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.1.tgz",
"integrity": "sha512-RzaGXLNt+CW+T41h1zl6pGz3EaeVhYlK+rdAap+7DxW5kqsqePO8kRtWPaCiVqdhZc86EctSPVYNix30YOMzmw==",
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.4.tgz",
"integrity": "sha512-PyofABPVv+d7fL7GOpusx7eRT9YETY2X04PhwbSipdj6bMxVCFJrr+nm0Mxqbf9hUiTin/UsnuFWBXlDZFy0Cw==",
"license": "MIT",
"dependencies": {
"binary": "^0.3.0",
"mkdirp": "^0.5.1"
@ -7902,9 +7908,9 @@
},
"dependencies": {
"@actions/artifact": {
"version": "2.1.8",
"resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-2.1.8.tgz",
"integrity": "sha512-kxgbllgF5f6mEdMeSW6WXlUbV1U77V9ECpA7LOYaY+Tm6RfXOm36EdXbpm+T9VPeaVqXK4QHLAgqay9GSyClgw==",
"version": "2.1.11",
"resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-2.1.11.tgz",
"integrity": "sha512-V/N/3yM3oLxozq2dpdGqbd/39UbDOR54bF25vYsvn3QZnyZERSzPjTAAwpGzdcwESye9G7vnuhPiKQACEuBQpg==",
"requires": {
"@actions/core": "^1.10.0",
"@actions/github": "^5.1.1",
@ -7916,7 +7922,6 @@
"@octokit/request-error": "^5.0.0",
"@protobuf-ts/plugin": "^2.2.3-alpha.1",
"archiver": "^7.0.1",
"crypto": "^1.0.1",
"jwt-decode": "^3.1.2",
"twirp-ts": "^2.5.0",
"unzip-stream": "^0.3.1"
@ -7936,12 +7941,20 @@
}
},
"@actions/core": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz",
"integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==",
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.11.1.tgz",
"integrity": "sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==",
"requires": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
"@actions/exec": "^1.1.1",
"@actions/http-client": "^2.0.1"
}
},
"@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"requires": {
"@actions/io": "^1.0.1"
}
},
"@actions/github": {
@ -8036,11 +8049,11 @@
}
},
"@actions/glob": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.3.0.tgz",
"integrity": "sha512-tJP1ZhF87fd6LBnaXWlahkyvdgvsLl7WnreW1EZaC8JWjpMXmzqWzQVe/IEYslrkT9ymibVrKyJN4UMD7uQM2w==",
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.0.tgz",
"integrity": "sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==",
"requires": {
"@actions/core": "^1.2.6",
"@actions/core": "^1.9.1",
"minimatch": "^3.0.4"
},
"dependencies": {
@ -10373,11 +10386,6 @@
"which": "^2.0.1"
}
},
"crypto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig=="
},
"damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
@ -12562,12 +12570,12 @@
"dev": true
},
"micromatch": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"requires": {
"braces": "^3.0.2",
"braces": "^3.0.3",
"picomatch": "^2.3.1"
}
},
@ -12822,9 +12830,9 @@
}
},
"path-to-regexp": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
"integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz",
"integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ=="
},
"path-type": {
"version": "4.0.0",
@ -13651,9 +13659,9 @@
"integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ=="
},
"unzip-stream": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.1.tgz",
"integrity": "sha512-RzaGXLNt+CW+T41h1zl6pGz3EaeVhYlK+rdAap+7DxW5kqsqePO8kRtWPaCiVqdhZc86EctSPVYNix30YOMzmw==",
"version": "0.3.4",
"resolved": "https://registry.npmjs.org/unzip-stream/-/unzip-stream-0.3.4.tgz",
"integrity": "sha512-PyofABPVv+d7fL7GOpusx7eRT9YETY2X04PhwbSipdj6bMxVCFJrr+nm0Mxqbf9hUiTin/UsnuFWBXlDZFy0Cw==",
"requires": {
"binary": "^0.3.0",
"mkdirp": "^0.5.1"

View File

@ -1,6 +1,6 @@
{
"name": "upload-artifact",
"version": "4.4.0",
"version": "4.4.3",
"description": "Upload an Actions Artifact in a workflow run",
"main": "dist/upload/index.js",
"scripts": {
@ -29,10 +29,10 @@
},
"homepage": "https://github.com/actions/upload-artifact#readme",
"dependencies": {
"@actions/artifact": "2.1.8",
"@actions/core": "^1.10.1",
"@actions/artifact": "^2.1.11",
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.0",
"@actions/glob": "^0.3.0",
"@actions/glob": "^0.5.0",
"@actions/io": "^1.1.2",
"minimatch": "^9.0.3"
},

View File

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

View File

@ -10,7 +10,7 @@ export function getInputs(): MergeInputs {
const pattern = core.getInput(Inputs.Pattern, {required: true})
const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
const includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
const inputs = {
name,
@ -19,7 +19,7 @@ export function getInputs(): MergeInputs {
deleteMerged,
retentionDays: 0,
compressionLevel: 6,
includeGitDirectory
includeHiddenFiles
} as MergeInputs
const retentionDaysStr = core.getInput(Inputs.RetentionDays)

View File

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

View File

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

View File

@ -11,11 +11,12 @@ export interface SearchResult {
rootDirectory: string
}
function getDefaultGlobOptions(): glob.GlobOptions {
function getDefaultGlobOptions(includeHiddenFiles: boolean): glob.GlobOptions {
return {
followSymbolicLinks: true,
implicitDescendants: true,
omitBrokenSymbolicLinks: true
omitBrokenSymbolicLinks: true,
excludeHiddenFiles: !includeHiddenFiles
}
}
@ -78,21 +79,15 @@ function getMultiPathLCA(searchPaths: string[]): string {
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(
searchPath: string,
searchOptions?: SearchOptions
includeHiddenFiles?: boolean
): Promise<SearchResult> {
const searchResults: string[] = []
const globber = await glob.create(searchPath, getDefaultGlobOptions())
const globber = await glob.create(
searchPath,
getDefaultGlobOptions(includeHiddenFiles || false)
)
const rawSearchResults: string[] = await globber.glob()
/*
@ -110,12 +105,6 @@ export async function findFilesToUpload(
// isDirectory() returns false for symlinks if using fs.lstat(), make sure to use fs.stat() instead
if (!fileStats.isDirectory()) {
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)
// detect any files that would be overwritten because of case insensitivity
@ -167,15 +156,3 @@ export async function findFilesToUpload(
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',
CompressionLevel = 'compression-level',
Overwrite = 'overwrite',
IncludeGitDirectory = 'include-git-directory'
IncludeHiddenFiles = 'include-hidden-files'
}
export enum NoFileOptions {

View File

@ -9,7 +9,7 @@ export function getInputs(): UploadInputs {
const name = core.getInput(Inputs.Name)
const path = core.getInput(Inputs.Path, {required: true})
const overwrite = core.getBooleanInput(Inputs.Overwrite)
const includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound)
const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound]
@ -29,7 +29,7 @@ export function getInputs(): UploadInputs {
searchPath: path,
ifNoFilesFound: noFileBehavior,
overwrite: overwrite,
includeGitDirectory: includeGitDirectory
includeHiddenFiles: includeHiddenFiles
} as UploadInputs
const retentionDaysStr = core.getInput(Inputs.RetentionDays)

View File

@ -24,9 +24,10 @@ async function deleteArtifactIfExists(artifactName: string): Promise<void> {
export async function run(): Promise<void> {
const inputs = getInputs()
const searchResult = await findFilesToUpload(inputs.searchPath, {
includeGitDirectory: inputs.includeGitDirectory
})
const searchResult = await findFilesToUpload(
inputs.searchPath,
inputs.includeHiddenFiles
)
if (searchResult.filesToUpload.length === 0) {
// No files were found, different use cases warrant different types of behavior if nothing is found
switch (inputs.ifNoFilesFound) {

View File

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