GitHub Actions Practice Questions
Prepare for GH-200 with more than an answer.
- Level
- Intermediate
- Valid for
- 2 years
Domains covered on the exam 4
- Author and maintain workflows40%
- Consume workflows20%
- Author and maintain actions25%
- Manage GitHub Actions for the enterprise15%
- 1
You are creating a workflow to build and push a Docker image to GitHub Container Registry (GHCR). You need to authenticate with the registry.
Which of the following is the BEST practice for authentication?
Show answer details
Correct answer: A
Using the
docker/login-actionis the standard way to authenticate. For GHCR,GITHUB_TOKENis the recommended credential, provided the workflow permissions (packages: write) are set correctly. - 2
A developer wants to use PowerShell Core (
pwsh) for a specific step on a Windows runner, instead of the default Windows PowerShell (powershell).How should they configure the step?
Show answer details
Correct answer: D
The
shellkeyword allows overriding the default shell. On Windows runners,pwshinvokes PowerShell Core, whilepowershellinvokes Windows PowerShell (Desktop). - 3
Which of the following activities can trigger a
pull_requestevent? (Select TWO)Show answer details
Correct answer: C, D
synchronizetriggers when commits are pushed to the pull request branch, updating the PR.openedis a standard activity type for pull_request events, triggering when a new PR is created. - 4
You have a job that runs on
ubuntu-latest. It clones the repository and builds a Java application. You notice the build fails because the repository files are found in/home/runner/work/repo-name/repo-namebut your script expects them in the root of the workspace.What is the default behavior of
actions/checkoutregarding the path, and is this likely the issue?Show answer details
Correct answer: B
The
actions/checkoutaction places code in$GITHUB_WORKSPACE(which maps to/home/runner/work/repo/repo). The default working directory for subsequent steps IS this directory. If the script fails, it might be looking elsewhere or the path assumption is wrong. - 5
What is the maximum execution time for a job on a GitHub-hosted runner before it is automatically cancelled?
Show answer details
Correct answer: B
The default timeout for a job on a GitHub-hosted runner is 6 hours (360 minutes). This can be adjusted downwards using
timeout-minutes. - 6
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 themainbranch 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?
Show answer details
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.
- 7
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?
Show answer details
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).
- 8
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
environmentinput can only be one of three values: 'dev', 'staging', or 'prod'.How should you define this input in the
workflow_dispatchtrigger?Show answer details
Correct answer: A
The
choiceinput 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.
