Deploying to GCP with GitHub Actions Quiz Quiz

Explore core concepts of deploying applications to Google Cloud Platform using GitHub Actions, focusing on automation, secrets management, workflow configuration, and troubleshooting best practices. This quiz will help reinforce essential principles and key steps for reliable cloud deployment pipelines.

  1. Workflow Trigger

    Which event should be configured in a GitHub Actions workflow to automatically deploy to GCP after merging changes to the 'main' branch?

    1. issued
    2. schedule
    3. release
    4. push

    Explanation: The 'push' event triggers the workflow when changes are pushed to a branch, making it ideal for automatic deployments after merges. 'issued' is not a valid workflow event. 'schedule' is used for periodic runs, not related to branch updates. 'release' is only appropriate when a release is published, not for general branch deployments.

  2. Service Account Secrets

    In a deployment workflow to GCP, what is the recommended method for securely storing and accessing the GCP service account key?

    1. Add it directly in the workflow YAML under environment variables
    2. Encode it in base64 and paste it into workflow steps
    3. Include it as a plain text file in the repository
    4. Store it in encrypted repository secrets

    Explanation: Storing sensitive information like service account keys in encrypted repository secrets is the secure and recommended best practice. Keeping it as a plain text file or directly in the workflow file exposes the key to unauthorized access. Base64 encoding does not provide any security; it only changes the format, not the protection, so direct pasting is unsafe.

  3. Setting Up Authentication

    Before running deployment steps in a GitHub Actions workflow that interacts with GCP, what action must always precede resource deployment?

    1. Update local configuration files
    2. Push new changes to another branch
    3. Activate authentication using the service account credentials
    4. Install a virtual machine

    Explanation: Authenticating with service account credentials is essential to grant permissions for deployment. Updating local configuration files is related to local development, not the workflow. Creating a virtual machine is a separate infrastructure task and not always required. Pushing changes to another branch is irrelevant for triggering cloud authentication.

  4. YAML Workflow Errors

    If your deployment workflow is not triggering as expected, which YAML configuration mistake is most likely the cause?

    1. Incorrect event syntax in the 'on' field
    2. Using dashes instead of colons for key-value pairs
    3. Omitting the 'run' keyword inside steps
    4. Missing comments at the top of the file

    Explanation: Having incorrect syntax or specifying the wrong event type in the 'on' field will prevent the workflow from running as intended. Omitting 'run' can cause steps to fail, but it doesn't prevent the workflow from triggering. Comments are optional and do not affect execution. YAML syntax uses colons, but using dashes outside of lists rarely disables triggering.

  5. Environment Variables Use

    Why is it considered best practice to reference environment variables for values like project IDs or region names in a deployment workflow?

    1. It is only necessary when using scheduled events
    2. It ensures credentials are always visible in logs for debugging
    3. It slows down the workflow execution for security
    4. It simplifies workflow updation and helps avoid hard-coding settings

    Explanation: Referencing environment variables keeps configurations flexible and reduces the need to change multiple lines when updating values like project IDs or regions. It does not intentionally slow down execution or make credentials visible in logs—those are security risks. Using environment variables is a good practice for all workflows, not only scheduled ones.