GitHub Actions の artifact とは?
artifact はジョブが実行からアップロードするファイルまたはフォルダで、ダウンロードや他のジョブからの利用が可能です。
ランナーは一時的なので、ジョブが生成するもの、ビルド、テストレポート、バイナリは、保存しなければ消えてしまいます。artifact を使うと、それらの出力を永続化し、ジョブ間で受け渡せます。
それは何か
artifact は、actions/upload-artifact で実行中にアップロードされ、actions/download-artifact で取得される、名前付きのファイルのバンドルです。
Uploading an artifact
steps:
- uses: actions/upload-artifact@v4
with:
name: build-output
path: dist/どう動くか
upload の action は path を zip 化して名前の下に保存します。後で同じ実行内で別のジョブがそれをダウンロードでき、実行後は設定可能な保持期間だけ利用可能なままです。
artifact と cache
artifact はダウンロードや下流のジョブのために実行の出力を捕捉します。cache は純粋に将来の実行を高速化するために存在します。似て見えますが、異なる目的を果たします。
なぜ重要か
artifact はビルド出力をジョブ間で移動させ(ビルドしてから deploy)、ログやレポートといった証跡を保存します。保持期間とサイズはストレージ使用量とコストに影響します。
関連する概念
artifact は upload/download の action を介して生成され、actions/cache と対比されます。しばしば needs でリンクされたジョブ間でデータを運びます。
重要なポイント
- artifact は実行からのファイルを永続化します。
upload-artifactでアップロードし、download-artifactで取得します。- artifact は出力を共有し、cache は将来の実行を高速化します。
関連ガイド
What Is actions/cache in GitHub Actions?actions/cache stores and restores files like dependencies between runs using a key, speeding up workflows by…
What Is a Job in GitHub Actions?A job in GitHub Actions is a group of steps that runs on a single runner. Jobs run in parallel by default and…
What Is the needs Keyword in GitHub Actions?The needs keyword makes one job wait for another to finish, creating a dependency graph and giving access to…
What Is a Job Summary in GitHub Actions?A job summary is custom Markdown a step writes to GITHUB_STEP_SUMMARY, rendered on the run page to surface re…