GitHub Actions Free Sample Questions

Description

Covers workflow triggers, components, secrets and environment variables, interpreting and managing workflow runs, logs and artifacts, and distributing actions and managing runners for the enterprise.

17 free sample questions250 in the full practice test

Try simulator

GH-200 Sample Questions

  1. Question 1

    Intermediate

    Author and maintain workflows · Work with events that trigger workflows

    You are architecting a CI/CD workflow for a monorepo containing a frontend application (in /client) and a backend API (in /api). You need to configure the workflow to trigger ONLY when changes are pushed to the main branch affecting the backend API code. Changes to documentation (Markdown files) inside the api directory should NOT trigger the workflow.

    Which trigger configuration should you use?

    Answer and explanation

    Correct answer: B

    This configuration correctly targets the 'main' branch and uses 'paths' to include the api directory while simultaneously using 'paths-ignore' to exclude markdown files within that structure. Both filters are evaluated to determine if the workflow runs.

  2. Question 2

    Beginner

    Author and maintain workflows · Work with events that trigger workflows

    A DevOps engineer is configuring a scheduled workflow that must run every Monday at 8:00 AM UTC. The workflow is critical for weekly reporting.

    Which cron schedule expression correctly implements this requirement?

    Answer and explanation

    Correct answer: C

    GitHub Actions uses POSIX cron syntax: Minute, Hour, Day of Month, Month, Day of Week. '0 8 * * 1' translates to Minute 0, Hour 8, Any Day of Month, Any Month, Day of Week 1 (Monday).

  3. Question 3

    Intermediate

    Author and maintain workflows · Work with events that trigger workflows

    You are creating a workflow that accepts manual inputs to deploy a specific version of an application to a chosen environment. You need to ensure the environment input can only be one of three values: 'dev', 'staging', or 'prod'.

    How should you define this input in the workflow_dispatch trigger?

    Answer and explanation

    Correct answer: A

    The choice input type renders a dropdown menu in the GitHub UI, restricting the user to select from the provided options list. This enforces the constraint at the UI level.

  4. Question 4

    Advanced

    Author and maintain workflows · Use the components of a workflow

    CASE STUDY: GlobalLogistics Corp

    GlobalLogistics has a complex deployment pipeline. The workflow deploy.yml consists of three jobs: build, test, and deploy.

    Requirements:

    1. build must run first.
    2. test must run only if build succeeds.
    3. deploy must run only if test succeeds.
    4. If test fails, a special cleanup job called report-failure must run to upload logs to an S3 bucket.

    How should you configure the report-failure job dependencies?

    Answer and explanation

    Correct answer: C

    To run a job after another job has failed, you must declare the dependency using needs: test (so it waits for test to finish) and use the if: failure() conditional check to ensure it only executes when the dependent job has failed.

  5. Question 5

    IntermediateMultiple answers

    Author and maintain workflows · Use the components of a workflow

    You need to select a runner for a job that requires a Linux environment with 64GB of RAM and custom GPU drivers installed. You have configured a self-hosted runner with these specifications and assigned it the labels: linux, x64, gpu, and high-mem.

    Which runs-on configuration ensures the job lands on this specific runner or one with identical capabilities? (Select TWO)

    Answer and explanation

    Correct answers: B, C

    When providing an array to runs-on, GitHub Actions selects a runner that matches ALL specified labels. This ensures the job runs on a self-hosted Linux machine with the required high-mem and gpu capabilities.

    Using the explicit group and labels syntax is also a valid way to target self-hosted runners, ensuring the runner is picked from a specific group and matches the required labels.

  6. Question 6

    Intermediate

    Author and maintain workflows · Use encrypted secrets and environment variables

    A developer defines an environment variable API_KEY at the workflow level, but redefines it with a different value in a specific job, and again within a specific step.

    When the step executes, which value of API_KEY will be used?

    Answer and explanation

    Correct answer: D

    GitHub Actions follows a specific precedence order for environment variables: Step level > Job level > Workflow level. The most specific definition (step level) overrides broader definitions.

  7. Question 7

    Intermediate

    Author and maintain workflows · Use encrypted secrets and environment variables

    You are maintaining a public repository. A contributor submits a Pull Request from a forked repository. Your workflow normally runs integration tests using a secret DB_PASSWORD.

    Why does the workflow fail when triggered by the PR from the fork?

    Answer and explanation

    Correct answer: D

    For security reasons, GitHub Actions prevents secrets from being accessed in workflows triggered by pull requests from forks. This prevents malicious code in a fork from stealing secrets. To support this, you typically use the pull_request_target event with caution.

  8. Question 8

    Intermediate

    Author and maintain workflows · Create a workflow for a particular purpose

    Your workflow requires a Redis database for integration testing. You want to configure a service container for Redis that is accessible to the job steps.

    Which configuration correctly sets up the Redis service and maps the port?

    Answer and explanation

    Correct answer: B

    This configuration defines a service named 'redis' using the 'redis' image and maps host port 6379 to container port 6379, making it accessible to the job steps via localhost:6379.

Register free for 9 more questions

Or unlock all 250 GH-200 questions with explanations, timed mode and flashcards.