Compare commits
10 Commits
main
...
robherley/
Author | SHA1 | Date |
---|---|---|
Rob Herley | c8d1cdcfdc | |
Rob Herley | fc784dd79b | |
Rob Herley | d5febab9d6 | |
Rob Herley | fd1ae7b288 | |
Rob Herley | b41dcc96e0 | |
Rob Herley | 8ceeef4d01 | |
Rob Herley | 62aa42dc97 | |
Rob Herley | d7195ef93f | |
Rob Herley | dba6fa8064 | |
Rob Herley | 6c1d23ca18 |
|
@ -22,7 +22,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
id: update-major-tag
|
id: update-major-tag
|
||||||
uses: actions/publish-action@v0.3.0
|
uses: actions/publish-action@v0.2.1
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|
|
@ -141,16 +141,12 @@ jobs:
|
||||||
}
|
}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: 'Alter file 1 content'
|
|
||||||
run: |
|
|
||||||
echo "This file has changed" > path/to/dir-1/file1.txt
|
|
||||||
|
|
||||||
# Replace the contents of Artifact #1
|
# Replace the contents of Artifact #1
|
||||||
- name: 'Overwrite artifact #1'
|
- name: 'Overwrite artifact #1 again'
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
name: 'Artifact-A-${{ matrix.runs-on }}'
|
name: 'Artifact-A-${{ matrix.runs-on }}'
|
||||||
path: path/to/dir-1/file1.txt
|
path: path/to/dir-2/file2.txt
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|
||||||
# Download replaced Artifact #1 and verify the correctness of the content
|
# Download replaced Artifact #1 and verify the correctness of the content
|
||||||
|
@ -162,90 +158,13 @@ jobs:
|
||||||
|
|
||||||
- name: 'Verify Artifact #1 again'
|
- name: 'Verify Artifact #1 again'
|
||||||
run: |
|
run: |
|
||||||
$file = "overwrite/some/new/path/file1.txt"
|
$file = "overwrite/some/new/path/file2.txt"
|
||||||
if(!(Test-Path -path $file))
|
if(!(Test-Path -path $file))
|
||||||
{
|
{
|
||||||
Write-Error "Expected file does not exist"
|
Write-Error "Expected file does not exist"
|
||||||
}
|
}
|
||||||
if(!((Get-Content $file) -ceq "This file has changed"))
|
if(!((Get-Content $file) -ceq "Hello world from file #2"))
|
||||||
{
|
{
|
||||||
Write-Error "File contents of downloaded artifact are incorrect"
|
Write-Error "File contents of downloaded artifacts are incorrect"
|
||||||
}
|
}
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
merge:
|
|
||||||
name: Merge
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
# Merge all artifacts from previous jobs
|
|
||||||
- name: Merge all artifacts in run
|
|
||||||
uses: ./merge/
|
|
||||||
with:
|
|
||||||
# our matrix produces artifacts with the same file, this prevents "stomping" on each other, also makes it
|
|
||||||
# easier to identify each of the merged artifacts
|
|
||||||
separate-directories: true
|
|
||||||
- name: 'Download merged artifacts'
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: merged-artifacts
|
|
||||||
path: all-merged-artifacts
|
|
||||||
- name: 'Check merged artifact has directories for each artifact'
|
|
||||||
run: |
|
|
||||||
$artifacts = @(
|
|
||||||
"Artifact-A-ubuntu-latest",
|
|
||||||
"Artifact-A-macos-latest",
|
|
||||||
"Artifact-A-windows-latest",
|
|
||||||
"Artifact-Wildcard-ubuntu-latest",
|
|
||||||
"Artifact-Wildcard-macos-latest",
|
|
||||||
"Artifact-Wildcard-windows-latest",
|
|
||||||
"Multi-Path-Artifact-ubuntu-latest",
|
|
||||||
"Multi-Path-Artifact-macos-latest",
|
|
||||||
"Multi-Path-Artifact-windows-latest"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($artifact in $artifacts) {
|
|
||||||
$path = "all-merged-artifacts/$artifact"
|
|
||||||
if (!(Test-Path $path)) {
|
|
||||||
Write-Error "$path does not exist."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
# Merge Artifact-A-* from previous jobs
|
|
||||||
- name: Merge all Artifact-A
|
|
||||||
uses: ./merge/
|
|
||||||
with:
|
|
||||||
name: Merged-Artifact-As
|
|
||||||
pattern: 'Artifact-A-*'
|
|
||||||
separate-directories: true
|
|
||||||
|
|
||||||
# Download merged artifacts and verify the correctness of the content
|
|
||||||
- name: 'Download merged artifacts'
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: Merged-Artifact-As
|
|
||||||
path: merged-artifact-a
|
|
||||||
|
|
||||||
- name: 'Verify merged artifacts'
|
|
||||||
run: |
|
|
||||||
$files = @(
|
|
||||||
"merged-artifact-a/Artifact-A-ubuntu-latest/file1.txt",
|
|
||||||
"merged-artifact-a/Artifact-A-macos-latest/file1.txt",
|
|
||||||
"merged-artifact-a/Artifact-A-windows-latest/file1.txt"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach ($file in $files) {
|
|
||||||
if (!(Test-Path $file)) {
|
|
||||||
Write-Error "$file does not exist."
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!((Get-Content $file) -ceq "This file has changed")) {
|
|
||||||
Write-Error "$file has incorrect content."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shell: pwsh
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/artifact"
|
name: "@actions/artifact"
|
||||||
version: 2.1.8
|
version: 2.1.0
|
||||||
type: npm
|
type: npm
|
||||||
summary:
|
summary:
|
||||||
homepage:
|
homepage:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.10.1
|
version: 1.10.0
|
||||||
type: npm
|
type: npm
|
||||||
summary:
|
summary:
|
||||||
homepage:
|
homepage:
|
||||||
|
|
10
README.md
10
README.md
|
@ -1,11 +1,5 @@
|
||||||
# `@actions/upload-artifact`
|
# `@actions/upload-artifact`
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> actions/upload-artifact@v3 is scheduled for deprecation on **November 30, 2024**. [Learn more.](https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/)
|
|
||||||
> Similarly, v1/v2 are scheduled for deprecation on **June 30, 2024**.
|
|
||||||
> Please update your workflow to use v4 of the artifact actions.
|
|
||||||
> This deprecation will not impact any existing versions of GitHub Enterprise Server being used by customers.
|
|
||||||
|
|
||||||
Upload [Actions Artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) from your Workflow Runs. Internally powered by [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/artifact) package.
|
Upload [Actions Artifacts](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) from your Workflow Runs. Internally powered by [@actions/artifact](https://github.com/actions/toolkit/tree/main/packages/artifact) package.
|
||||||
|
|
||||||
See also [download-artifact](https://github.com/actions/download-artifact).
|
See also [download-artifact](https://github.com/actions/download-artifact).
|
||||||
|
@ -47,8 +41,6 @@ The release of upload-artifact@v4 and download-artifact@v4 are major changes to
|
||||||
|
|
||||||
For more information, see the [`@actions/artifact`](https://github.com/actions/toolkit/tree/main/packages/artifact) documentation.
|
For more information, see the [`@actions/artifact`](https://github.com/actions/toolkit/tree/main/packages/artifact) documentation.
|
||||||
|
|
||||||
There is also a new sub-action, `actions/upload-artifact/merge`. For more info, check out that action's [README](./merge/README.md).
|
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
1. Uploads are significantly faster, upwards of 90% improvement in worst case scenarios.
|
1. Uploads are significantly faster, upwards of 90% improvement in worst case scenarios.
|
||||||
|
@ -414,7 +406,7 @@ jobs:
|
||||||
|
|
||||||
### Number of Artifacts
|
### Number of Artifacts
|
||||||
|
|
||||||
Within an individual job, there is a limit of 500 artifacts that can be created for that job.
|
Within an individual job, there is a limit of 10 artifacts that can be created for that job.
|
||||||
|
|
||||||
You may also be limited by Artifacts if you have exceeded your shared storage quota. Storage is calculated every 6-12 hours. See [the documentation](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending) for more info.
|
You may also be limited by Artifacts if you have exceeded your shared storage quota. Storage is calculated every 6-12 hours. See [the documentation](https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending) for more info.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import artifact from '@actions/artifact'
|
import artifact from '@actions/artifact'
|
||||||
import {run} from '../src/merge/merge-artifacts'
|
import {run} from '../src/merge/merge-artifact'
|
||||||
import {Inputs} from '../src/merge/constants'
|
import {Inputs} from '../src/merge/constants'
|
||||||
import * as search from '../src/shared/search'
|
import * as search from '../src/shared/search'
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ jest.mock('fs/promises', () => ({
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
const mockInputs = (overrides?: Partial<{[K in Inputs]?: any}>) => {
|
const mockInputs = (overrides?: Partial<{[K in Inputs]?: any}>) => {
|
||||||
const inputs = {
|
const inputs = {
|
||||||
[Inputs.Name]: 'my-merged-artifact',
|
[Inputs.Into]: 'my-merged-artifact',
|
||||||
[Inputs.Pattern]: '*',
|
[Inputs.Pattern]: '*',
|
||||||
[Inputs.SeparateDirectories]: false,
|
[Inputs.SeparateDirectories]: false,
|
||||||
[Inputs.RetentionDays]: 0,
|
[Inputs.RetentionDays]: 0,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,6 @@
|
||||||
- [Migration](#migration)
|
- [Migration](#migration)
|
||||||
- [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)
|
|
||||||
|
|
||||||
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`.
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ jobs:
|
||||||
- name: Download All Artifacts
|
- name: Download All Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: my-artifact
|
|
||||||
path: my-artifact
|
path: my-artifact
|
||||||
- run: ls -R my-artifact
|
- run: ls -R my-artifact
|
||||||
```
|
```
|
||||||
|
@ -74,7 +72,6 @@ jobs:
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
+ uses: actions/download-artifact@v4
|
+ uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
- name: my-artifact
|
|
||||||
path: my-artifact
|
path: my-artifact
|
||||||
+ pattern: my-artifact-*
|
+ pattern: my-artifact-*
|
||||||
+ merge-multiple: true
|
+ merge-multiple: true
|
||||||
|
@ -145,65 +142,3 @@ jobs:
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that this will create an _entirely_ new Artifact, with a different ID from the previous.
|
Note that this will create an _entirely_ new Artifact, with a different ID from the previous.
|
||||||
|
|
||||||
## Merging multiple artifacts
|
|
||||||
|
|
||||||
In `v3`, multiple uploads from multiple jobs could be done to the same Artifact. This would result in a single archive, which could be useful for sending to upstream systems outside of Actions via API or UI downloads.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
upload:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
runs-on: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
|
||||||
steps:
|
|
||||||
- name: Create a File
|
|
||||||
run: echo "hello from ${{ matrix.runs-on }}" > file-${{ matrix.runs-on }}.txt
|
|
||||||
- name: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: all-my-files # NOTE: same artifact name
|
|
||||||
path: file-${{ matrix.runs-on }}.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
The single `all-my-files` artifact would contain the following:
|
|
||||||
|
|
||||||
```
|
|
||||||
.
|
|
||||||
∟ file-ubuntu-latest.txt
|
|
||||||
∟ file-macos-latest.txt
|
|
||||||
∟ file-windows-latest.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
To achieve the same in `v4` you can change it like so:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
jobs:
|
|
||||||
upload:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
runs-on: [ubuntu-latest, macos-latest, windows-latest]
|
|
||||||
runs-on: ${{ matrix.runs-on }}
|
|
||||||
steps:
|
|
||||||
- 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
|
|
||||||
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-*
|
|
||||||
```
|
|
||||||
|
|
||||||
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).
|
|
||||||
|
|
143
merge/README.md
143
merge/README.md
|
@ -7,10 +7,6 @@ Merge multiple [Actions Artifacts](https://docs.github.com/en/actions/using-work
|
||||||
- [Inputs](#inputs)
|
- [Inputs](#inputs)
|
||||||
- [Outputs](#outputs)
|
- [Outputs](#outputs)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [Combining all artifacts in a workflow run](#combining-all-artifacts-in-a-workflow-run)
|
|
||||||
- [Prefix directories in merged artifact](#prefix-directories-in-merged-artifact)
|
|
||||||
- [Deleting artifacts after merge](#deleting-artifacts-after-merge)
|
|
||||||
- [Retention and Compression Level](#retention-and-compression-level)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
@ -19,18 +15,14 @@ Merge multiple [Actions Artifacts](https://docs.github.com/en/actions/using-work
|
||||||
|
|
||||||
Note: this actions can only merge artifacts created with actions/upload-artifact@v4+
|
Note: this actions can only merge artifacts created with actions/upload-artifact@v4+
|
||||||
|
|
||||||
This sub-action is a helper to merge multiple artifacts after they are created. To do so, it will download multiple artifacts to a temporary directory and reupload them as a single artifact.
|
|
||||||
|
|
||||||
For most cases, this may not be the most efficient solution. See [the migration docs](../docs/MIGRATION.md#multiple-uploads-to-the-same-named-artifact) on how to download multiple artifacts to the same directory on a runner. This action should only be necessary for cases where multiple artifacts will need to be downloaded outside the runner environment, like downloads via the UI or REST API.
|
|
||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/upload-artifact/merge@v4
|
- uses: actions/upload-artifact/merge@v4
|
||||||
with:
|
with:
|
||||||
# The name of the artifact that the artifacts will be merged into
|
# The name of the artifact that the artifacts will be merged into
|
||||||
# Optional. Default is 'merged-artifacts'
|
# Optional. Default is 'merged-artifact'
|
||||||
name:
|
into:
|
||||||
|
|
||||||
# A glob pattern matching the artifacts that should be merged.
|
# A glob pattern matching the artifacts that should be merged.
|
||||||
# Optional. Default is '*'
|
# Optional. Default is '*'
|
||||||
|
@ -68,133 +60,4 @@ For most cases, this may not be the most efficient solution. See [the migration
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
For each of these examples, assume we have a prior job matrix that generates three artifacts: `my-artifact-a`, `my-artifact-b` and `my-artifact-c`.
|
TODO(robherley): add examples
|
||||||
|
|
||||||
e.g.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
upload:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
foo: [a, b, c]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Run a one-line script
|
|
||||||
run: echo "hello from job ${{ matrix.foo }}" > file-${{ matrix.foo }}.txt
|
|
||||||
- name: Upload
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: my-artifact-${{ matrix.foo }}
|
|
||||||
path: file-${{ matrix.foo }}.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
Each of the following examples will use the `needs: upload` as a prerequesite before any merging operations.
|
|
||||||
|
|
||||||
### Combining all artifacts in a workflow run
|
|
||||||
|
|
||||||
By default (with no inputs), calling this action will take all the artifacts in the workflow run and combined them into a single artifact called `merged-artifacts`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
# ... <upload job> ...
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: upload
|
|
||||||
steps:
|
|
||||||
- name: Merge Artifacts
|
|
||||||
uses: actions/upload-artifact/merge@v4
|
|
||||||
```
|
|
||||||
|
|
||||||
This will result in an artifact called `merged-artifacts` with the following content:
|
|
||||||
|
|
||||||
```
|
|
||||||
.
|
|
||||||
∟ file-a.txt
|
|
||||||
∟ file-b.txt
|
|
||||||
∟ file-c.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
To change the name of the artifact and filter on what artifacts are added, you can use the `name` and `pattern` inputs:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
# ... <upload job> ...
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: upload
|
|
||||||
steps:
|
|
||||||
- name: Merge Artifacts
|
|
||||||
uses: actions/upload-artifact/merge@v4
|
|
||||||
with:
|
|
||||||
name: my-amazing-merged-artifact
|
|
||||||
pattern: my-artifact-*
|
|
||||||
```
|
|
||||||
|
|
||||||
### Prefix directories in merged artifact
|
|
||||||
|
|
||||||
To prevent overwriting files in artifacts that may have the same name, you can use the `separate-directories` to prefix the extracted files with directories (named after the original artifact):
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
# ... <upload job> ...
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: upload
|
|
||||||
steps:
|
|
||||||
- name: Merge Artifacts
|
|
||||||
uses: actions/upload-artifact/merge@v4
|
|
||||||
with:
|
|
||||||
separate-directories: true
|
|
||||||
```
|
|
||||||
|
|
||||||
This will result in the following artifact structure:
|
|
||||||
|
|
||||||
```
|
|
||||||
.
|
|
||||||
∟ my-artifact-a
|
|
||||||
∟ file-a.txt
|
|
||||||
∟ my-artifact-b
|
|
||||||
∟ file-b.txt
|
|
||||||
∟ my-artifact-c
|
|
||||||
∟ file-c.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
### Deleting artifacts after merge
|
|
||||||
|
|
||||||
After merge, the old artifacts may no longer be required. To automatically delete them after they are merged into a new artifact, you can use `delete-merged` like so:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
# ... <upload job> ...
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: upload
|
|
||||||
steps:
|
|
||||||
- name: Merge Artifacts
|
|
||||||
uses: actions/upload-artifact/merge@v4
|
|
||||||
with:
|
|
||||||
delete-merged: true
|
|
||||||
```
|
|
||||||
|
|
||||||
After this runs, the matching artifact (`my-artifact-a`, `my-artifact-b` and `my-artifact-c`) will be merged.
|
|
||||||
|
|
||||||
### Retention and Compression Level
|
|
||||||
|
|
||||||
Similar to actions/upload-artifact, both [`retention-days`](../README.md#retention-period) and [`compression-level`](../README.md#altering-compressions-level-speed-v-size) are supported:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
jobs:
|
|
||||||
# ... <upload job> ...
|
|
||||||
merge:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: upload
|
|
||||||
steps:
|
|
||||||
- name: Merge Artifacts
|
|
||||||
uses: actions/upload-artifact/merge@v4
|
|
||||||
with:
|
|
||||||
retention-days: 1
|
|
||||||
compression-level: 9
|
|
||||||
```
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ name: 'Merge Build Artifacts'
|
||||||
description: 'Merge one or more build Artifacts'
|
description: 'Merge one or more build Artifacts'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
name:
|
into:
|
||||||
description: 'The name of the artifact that the artifacts will be merged into.'
|
description: 'The name of the artifact that the artifacts will be merged into.'
|
||||||
required: true
|
required: true
|
||||||
default: 'merged-artifacts'
|
default: 'merged-artifact'
|
||||||
pattern:
|
pattern:
|
||||||
description: 'A glob pattern matching the artifact names that should be merged.'
|
description: 'A glob pattern matching the artifact names that should be merged.'
|
||||||
default: '*'
|
default: '*'
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "upload-artifact",
|
"name": "upload-artifact",
|
||||||
"version": "4.3.6",
|
"version": "4.2.0",
|
||||||
"description": "Upload an Actions Artifact in a workflow run",
|
"description": "Upload an Actions Artifact in a workflow run",
|
||||||
"main": "dist/upload/index.js",
|
"main": "dist/upload/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/upload-artifact#readme",
|
"homepage": "https://github.com/actions/upload-artifact#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "2.1.8",
|
"@actions/artifact": "^2.1.0",
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.0",
|
||||||
"@actions/glob": "^0.3.0",
|
"@actions/glob": "^0.3.0",
|
||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable no-unused-vars */
|
/* eslint-disable no-unused-vars */
|
||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
Name = 'name',
|
Into = 'into',
|
||||||
Pattern = 'pattern',
|
Pattern = 'pattern',
|
||||||
SeparateDirectories = 'separate-directories',
|
SeparateDirectories = 'separate-directories',
|
||||||
RetentionDays = 'retention-days',
|
RetentionDays = 'retention-days',
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {run} from './merge-artifacts'
|
import {run} from './merge-artifact'
|
||||||
|
|
||||||
run().catch(error => {
|
run().catch(error => {
|
||||||
core.setFailed((error as Error).message)
|
core.setFailed((error as Error).message)
|
||||||
|
|
|
@ -6,13 +6,13 @@ import {MergeInputs} from './merge-inputs'
|
||||||
* Helper to get all the inputs for the action
|
* Helper to get all the inputs for the action
|
||||||
*/
|
*/
|
||||||
export function getInputs(): MergeInputs {
|
export function getInputs(): MergeInputs {
|
||||||
const name = core.getInput(Inputs.Name, {required: true})
|
const into = core.getInput(Inputs.Into, {required: true})
|
||||||
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 inputs = {
|
const inputs = {
|
||||||
name,
|
into,
|
||||||
pattern,
|
pattern,
|
||||||
separateDirectories,
|
separateDirectories,
|
||||||
deleteMerged,
|
deleteMerged,
|
||||||
|
|
|
@ -65,7 +65,7 @@ export async function run(): Promise<void> {
|
||||||
const searchResult = await findFilesToUpload(tmpDir)
|
const searchResult = await findFilesToUpload(tmpDir)
|
||||||
|
|
||||||
await uploadArtifact(
|
await uploadArtifact(
|
||||||
inputs.name,
|
inputs.into,
|
||||||
searchResult.filesToUpload,
|
searchResult.filesToUpload,
|
||||||
searchResult.rootDirectory,
|
searchResult.rootDirectory,
|
||||||
options
|
options
|
|
@ -2,7 +2,7 @@ export interface MergeInputs {
|
||||||
/**
|
/**
|
||||||
* The name of the artifact that the artifacts will be merged into
|
* The name of the artifact that the artifacts will be merged into
|
||||||
*/
|
*/
|
||||||
name: string
|
into: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A glob pattern matching the artifacts that should be merged.
|
* A glob pattern matching the artifacts that should be merged.
|
||||||
|
|
Loading…
Reference in New Issue