Skip to content

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?

  1. AFollow the redirect immediately after each call
  2. BCall the endpoint with Accept: application/zip to get the file inline
  3. CUse the jobs endpoint, whose links don't expire
  4. 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.

Question 2 · choose 1

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?

  1. Agh run download -n crash-report from the repository root
  2. Bgh run download 8812
  3. Cgh run rerun 8812 --debug
  4. 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.

Question 3 · choose 1

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?

  1. ARe-run all jobs so that every job is included in the next attempt's log archive
  2. BEnable debug logging and download the archive again
  3. CDownload the log archive of the earlier run attempt as well
  4. 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.

Question 4 · choose 1

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?

  1. AThe archive_download_url returned by the REST API
  2. BThe upload step's artifact-digest output
  3. CThe upload step's artifact-url output
  4. 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.

Question 5 · choose 1

A tester wants the installer that a workflow run uploaded as an artifact. Where on GitHub does she download it?

  1. AFrom the repository's Releases page
  2. BFrom the Artifacts section of the run's summary page
  3. CFrom the Packages tab of the repository
  4. DFrom the Set up job step of the run log
Show the answer and why
  • AFrom the repository's Releases page

    Incorrect

    Releases hold release assets, not workflow artifacts.

  • BFrom the Artifacts section of the run's summary page

    Correct

    Run summaries list the run's artifacts for download.

  • CFrom the Packages tab of the repository

    Incorrect

    Packages hold registry packages, not artifacts.

  • DFrom the Set up job step of the run log

    Incorrect

    That step records runner setup; it has no downloads.

Open the workflow run from the Actions tab; the run summary's Artifacts section lists the run's artifacts, and clicking one downloads it.

Question 6 · choose 1

From a terminal, a developer wants to read only the output of the failed steps of a job, not the whole log. Which command fits?

  1. Agh run view --job JOB_ID --verbose --log
  2. Bgh run list --limit 1
  3. Cgh run watch
  4. Dgh run view --job JOB_ID --log-failed
Show the answer and why
  • Agh run view --job JOB_ID --verbose --log

    Incorrect

    --log prints the whole log and --verbose adds the steps; neither keeps only failed steps.

  • Bgh run list --limit 1

    Incorrect

    That lists recent runs.

  • Cgh run watch

    Incorrect

    That follows a run's progress.

  • Dgh run view --job JOB_ID --log-failed

    Correct

    --log-failed filters the log to the failed steps.

gh run view --log prints a job's full log, and --log-failed prints only the logs of failed steps. --verbose adds job steps to the run summary.

Question 7 · choose 1

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?

  1. AThe job ID of the uploading job
  2. Bartifact
  3. CThe last folder in path
  4. 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.

Question 8 · choose 1

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?

  1. AEach artifact in its own directory named after it
  2. BOnly the first artifact is downloaded
  3. CAll files merged into the workspace root
  4. 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.

Practice domain 2 →Practice all domains →