GH-200 practice question 7 of 15
Without the need to use additional infrastructure, what is the simplest and most maintainable method for configuring a workflow job to provide access to an empty PostgreSQL database?
Full set: 100 questionsThe simplest and most maintainable method is to use service containers. This is a built-in feature of GitHub Actions that allows you to run additional Docker containers alongside your job's primary container on the same runner. These service containers can host databases, caches, or other dependencies. The workflow orchestrates the lifecycle of the service container, making it available on a shared network for the job's steps and then tearing it down automatically. This avoids the complexity and cost of managing external infrastructure.
B. Run the actions/postgres action in a parallel job: Jobs run in isolated environments by default and cannot easily share services like a database.
C. It is currently impossible to access the database with GitHub Actions: This is incorrect; service containers are a primary feature designed for this exact use case.
D. Dynamically provision and deprovision an environment: This requires external infrastructure (e.g., a cloud provider) and complex setup, violating the question's constraints.
GitHub Docs
"About service containers". This document explains
"Service containers are Docker containers that provide a simple and portable way for you to host services that you might need to test or operate your application in a workflow."
GitHub Docs
"Creating a PostgreSQL service container". This page provides a specific
documented example of how to configure a workflow job with a PostgreSQL service container
directly addressing the scenario in the question.
Keep practicing
Take the free GH-200 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GH-200 practice questions
- Question 1Which action type should be used to bundle a series of run steps into a reusable custom a…
- Question 2As a developer, which workflow steps should you perform to publish an image to the GitHub…
- Question 3Where should workflow files be stored to be triggered by events in a repository?
- Question 5Which default environment variable specifies the branch or tag that triggered a workflow?
- Question 6As a developer, what is the safest way to reference an action to prevent modification of …
- Question 8Disabling a workflow allows you to stop a workflow from being triggered without having to…
