Learn which GitHub Actions action is used to save artifacts generated by a workflow run. Understand how to persist data and share it between jobs.
Table of Contents
Question
Artifacts from a GitHub Actions workflow can be saved with what action?
A. The actions/upload-artifact action
B. The actions/checkout@v3 action
C. The actions/download-artifact action
Answer
A. The actions/upload-artifact action
Explanation
The actions/upload-artifact action allows you to save an artifact.
The actions/upload-artifact action is used to save artifacts from a GitHub Actions workflow run. This action allows you to specify which files and directories should be saved and persisted after the workflow completes.
To use the upload-artifact action, include a step like this in your job:
- uses: actions/upload-artifact@v3 with: name: my-artifact path: path/to/artifact/world.txt
This will save the file world.txt located at path/to/artifact/ as an artifact named “my-artifact”. You can specify multiple files or directories in the path input.
Artifacts are retained for 90 days by default, but this can be customized. They can be downloaded through the GitHub web UI or through the download-artifact action in another job or workflow. This allows sharing data between jobs in a workflow.
The other actions mentioned are used for different purposes:
- actions/checkout@v3 is used to check out your repository code into the workflow
- actions/download-artifact is used to download artifacts that were previously uploaded in the same workflow run
So in summary, the actions/upload-artifact action is the correct choice for saving artifacts from a workflow. It allows persisting generated files and sharing them between jobs as needed.
GitHub Actions certification exam assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the GitHub Actions exam and earn GitHub Actions certification.