GH-200 · Domain 2: Consume and troubleshoot workflows · 19% of the exam
Task 2.2: Access workflow artifacts and logs
Finding runs, logs and artifacts in the UI, with GitHub CLI and through the REST API, debug logging, and downloading and deleting artifacts.
Study it
Logs, debug logging and artifacts in the UI, GitHub CLI and the REST API
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the GitHub documentation page that proves it.
Question 1 · choose 1
A compliance script calls GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs, saves the Location header from the response, and downloads the archive from that URL in a batch job an hour later. The downloads fail. What should the script do?
AFollow the redirect immediately after each call
BCall the endpoint with Accept: application/zip to get the file inline
CUse the jobs endpoint, whose links don't expire
DRequest the logs after the retention period ends
Show the answer and why
AFollow the redirect immediately after each call
Correct
The endpoint returns 302 with a download link that expires after one minute.
BCall the endpoint with Accept: application/zip to get the file inline
Incorrect
The endpoint answers with a redirect, not with the archive in the body.
CUse the jobs endpoint, whose links don't expire
Incorrect
Job log downloads also redirect to short-lived links.
DRequest the logs after the retention period ends
Incorrect
After retention ends, the logs are deleted rather than archived.
Download workflow run logs returns 302 Found with a redirect URL to an archive of the run's log files. The link expires after 1 minute, so the client should follow the Location header right away.
An on-call engineer needs the crash-report artifact from run 8812 on her laptop, without opening a browser and without the run's other artifacts. Which command fits?
Agh run download -n crash-report from the repository root
Bgh run download 8812
Cgh run rerun 8812 --debug
Dgh run download 8812 -n crash-report
Show the answer and why
Agh run download -n crash-report from the repository root
Incorrect
Without a run ID, the command downloads crash-report artifacts across the repository's runs, not only run 8812.
Bgh run download 8812
Incorrect
Without -n, every artifact of the run is downloaded.
Cgh run rerun 8812 --debug
Incorrect
That starts a new attempt instead of downloading anything.
Dgh run download 8812 -n crash-report
Correct
-n limits the download to the named artifact.
gh run download RUN_ID downloads all artifacts of a run, and -n ARTIFACT_NAME downloads only the named artifact, which is extracted into the current directory when it is the only one.
A run's failed jobs were re-run and passed. An auditor needs the logs of every job in the run, but the downloaded log archive contains only the two jobs that were re-run. How can the auditor get the rest?
ARe-run all jobs so that every job is included in the next attempt's log archive
BEnable debug logging and download the archive again
CDownload the log archive of the earlier run attempt as well
DRead the logs from the artifacts of the run
Show the answer and why
ARe-run all jobs so that every job is included in the next attempt's log archive
Incorrect
That runs every job again and produces new logs instead of the originals.
BEnable debug logging and download the archive again
Incorrect
Debug logging adds detail to future runs; it doesn't change this archive.
CDownload the log archive of the earlier run attempt as well
Correct
The jobs that weren't re-run are in the archive of the attempt that ran them.
DRead the logs from the artifacts of the run
Incorrect
Logs aren't stored as artifacts unless a workflow uploads them.
When you download the log archive of a workflow that was partially re-run, the archive includes only the jobs that were re-run. For a complete set of logs, download the archives of the previous run attempts that ran the other jobs, which the Latest dropdown lists.
A pull request workflow builds a preview bundle and should post a comment with a direct link to that bundle's download. Reviewers are signed in to GitHub. The link must point at this exact upload, not the run page. What should the comment use?
AThe archive_download_url returned by the REST API
BThe upload step's artifact-digest output
CThe upload step's artifact-url output
Dgithub.server_url, the repository and the run ID joined together
Show the answer and why
AThe archive_download_url returned by the REST API
Incorrect
That API link needs a token and redirects to a short-lived URL, which a comment can't refresh.
BThe upload step's artifact-digest output
Incorrect
The digest verifies the content; it isn't a link.
CThe upload step's artifact-url output
Correct
The action returns a URL to download that artifact, which works for signed-in users until it expires.
Dgithub.server_url, the repository and the run ID joined together
Incorrect
That points at the run page, which the stem rules out.
actions/upload-artifact returns artifact-id, artifact-url and artifact-digest. artifact-url can link to the artifact from issues or pull requests; users must be signed in, and the URL works until the artifact expires or the run or repository is deleted. The REST download endpoint returns a redirect that expires after a minute.
A workflow's upload-artifact step sets only path. A second job that downloads by name can't find it. What name did the upload get?
AThe job ID of the uploading job
Bartifact
CThe last folder in path
DThe run number
Show the answer and why
AThe job ID of the uploading job
Incorrect
The job isn't used as a name.
Bartifact
Correct
Without a name, upload-artifact uses artifact.
CThe last folder in path
Incorrect
The path doesn't decide the name of a zipped upload.
DThe run number
Incorrect
Run numbers aren't used as names.
GitHub recommends naming each artifact. If no name is provided, the upload-artifact action uses the default name artifact, and download-artifact can download it by that name.
A packaging job runs download-artifact without a name or pattern. The run has three artifacts: linux, macos and windows. How are they laid out?
AEach artifact in its own directory named after it
BOnly the first artifact is downloaded
CAll files merged into the workspace root
DThree zip files that the download step leaves for the job to extract
Show the answer and why
AEach artifact in its own directory named after it
Correct
Downloading all artifacts creates one directory per artifact name.
BOnly the first artifact is downloaded
Incorrect
Without a name, every artifact of the run is downloaded.
CAll files merged into the workspace root
Incorrect
Without further inputs, the artifacts aren't merged into one place.
DThree zip files that the download step leaves for the job to extract
Incorrect
The action extracts zipped artifacts.
download-artifact downloads all artifacts of the run when no name is given, creating a directory for each artifact using its name, and it extracts each zipped artifact.