Artifacts
Mint can extract artifacts from your task once it has finished running. These artifacts can be downloaded in the Mint UI and used in subsequent tasks.
Example
Consider a task which runs your test suite and tracks code coverage statistics. Without artifacts, you might upload those coverage results within the same task. However, with artifacts, you can extract the coverage results and use them in another task.
tasks:
- key: run-tests
run: ./run-my-tests.sh
outputs:
artifacts:
- key: coverage
path: tmp/coverage
- key: upload-coverage
after: ${{ run-tests.succeeded || run-tests.failed }}
run: ./upload-coverage.sh $COVERAGE_DIR
env:
COVERAGE_DIR: ${{ tasks.run-tests.artifacts.coverage.path }}
Files
When path
points to a file in your task's filesystem, Mint will produce a .tar.gz
archive which contains your file
at the root. For example, if path
were some/path/to/file.txt
, the artifact would contain file.txt
at the root.
When you reference the artifact with a Mint expression to use in a subsequent task, it'll point to file.txt
directly.
This lets you use the artifact path as if it were a bash variable.
Directories
When path
points to a directory in your task's filesystem, Mint will produce a .tar.gz
archive which contains
the contents of that directory at the root of the archive. For example, if path
were some/path
and some/path
contains both hello.txt
and world.txt
, the artifact would contain those two files at the root.
When you reference the artifact with a Mint expression to use in a subsequent task, it'll point to directory containing those files directly. Like files, this lets you use the artifact path as if it were a bash variable.
Filtering
Directory artifacts (including the .mint
directory via ${{ run.mint-dir }}
) can be filtered just like
the filesystem of a task to improve cache hits when using artifact contents. You can filter
artifacts with the following syntax:
tasks:
- key: upload-artifact
run: |
mkdir -p path/to/my-artifact
echo one | tee path/to/my-artifact/one.txt
echo two | tee path/to/my-artifact/two.txt
outputs:
artifacts:
- key: my-artifact
path: path/to/my-artifact
- key: use-only-one-txt
run: |
ls ${{ tasks.upload-artifact.artifacts.my-artifact.path }}
cat ${{ tasks.upload-artifact.artifacts.my-artifact.path }}/one.txt
filter:
${{ tasks.upload-artifact.artifacts.my-artifact }}:
- one.txt
If you also need to filter the workspace, you can specify the workspace
key within filter
:
tasks:
- key: files
run: |
echo a | tee a.txt
echo b | tee b.txt
- key: upload-artifact
run: |
mkdir -p path/to/my-artifact
echo one | tee path/to/my-artifact/one.txt
echo two | tee path/to/my-artifact/two.txt
outputs:
artifacts:
- key: my-artifact
path: path/to/my-artifact
- key: use-only-one-txt-and-a-txt
use: files
run: |
ls ./
cat a.txt
ls ${{ tasks.upload-artifact.artifacts.my-artifact.path }}
cat ${{ tasks.upload-artifact.artifacts.my-artifact.path }}/one.txt
filter:
workspace:
- a.txt
${{ tasks.upload-artifact.artifacts.my-artifact }}:
- one.txt