Table of Contents
Prepare for GitHub Action Certifications with this Github Actions Practice Exam with more than 50+ question, that are similar to real exam.
Q1: Which matrix job definition is syntactically correct?
jobs:
example_matrix:
strategy:
matrix:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
jobs:
example_matrix:
matrix:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
jobs:
example_matrix:
matrix:
strategy:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
jobs:
matrix:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
Reveal Solution
jobs:
example_matrix:
strategy:
matrix:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
Here’s why the other options are incorrect:
- Option 1 (jobs nested under itself): You can’t nest the same job name (“example_matrix”) under itself.
- Option 2 (missing ‘strategy’ key): The
matrix
definition needs to be under thestrategy
key. - Option 3 (missing ‘strategy’ key): Same error as option 2.
- Option 4 (missing job name): The top-level
matrix
definition needs to be under a named job.
The correct option defines a job named “example_matrix” with a strategy that uses a matrix for combining different versions and operating systems.
Q2: Which event is triggered by a webhook action from outside of the repository?
workflow_dispatch
webhook_dispatch
api_dispatch
repository_dispatch
remote_dispatch
Reveal Solution
Out of the provided options, the event triggered by a webhook action from outside of the repository is:
repository_dispatch
Here’s why the other options are not relevant:
- workflow_dispatch: This event is triggered when a manual workflow run is initiated directly within the repository.
- api_dispatch: This event doesn’t exist in most popular CI/CD platforms like GitHub Actions or GitLab CI/CD.
- webhook_dispatch is a broader term and doesn’t necessarily specify the origin of the webhook.
- remote_dispatch is not a commonly used term in this context.
repository_dispatch specifically allows external systems to trigger workflows in your repository by sending a webhook notification with a custom event type. This enables communication and automation between your repository and external tools.
Q3: Which keyword allows you to define environment variables in a GitHub Actions workflow?
vars
env
secrets
config
Reveal Solution
The keyword that allows you to define environment variables in a GitHub Actions workflow is:
env
Here’s why the other options are not used for defining environment variables:
- vars: While
vars
is a context used to access environment variables within your workflow steps, it’s not used for defining them. - secrets: This keyword is used to define secrets within your workflow, which are encrypted and not directly accessible in steps. You can reference secrets and use them as environment variables, but they are managed separately.
- config: This keyword is generally used for defining the overall configuration of your workflow, not specifically for environment variables.
Q4: Your open-source publicly available repository contains a workflow with a pull_request
event trigger. How can you require approvals for workflow runs triggered from forks of your repository?
The workflow will not trigger for forks if using pull_request event. If you want to do that you should use fork_pull_request event trigger with require-approval flag.
Setup deployment protection rules for the repository.
Setup branch protection rules for the repository.
Setup required approvals for fork runs in the repository
Reveal Solution
The correct option is:
Setup required approvals for fork runs in the repository
Because of following reasons:
- Workflows with the
pull_request
event trigger only run on the base repository, not forks. - To require approval for workflows triggered by pull requests from forks, you need to specifically configure approval settings for fork runs.
Q5: You defined a matrix job example_matrix
. How can limit the matrix to run a maximum of 2 jobs at a time?
jobs:
example_matrix:
strategy:
matrix:
version: [10, 12, 14]
os: [ubuntu-latest, windows-latest]
Set jobs.example_matrix.strategy.concurrency
to 2
It's not possible, a matrix will always run all of the jobs in parallel if there are runners available
Set jobs.example_matrix.strategy.max-parallel
to 2
Use Github's REST API to check if the job count is lesser than 2
Reveal Solution
The correct answer is:
Set jobs.example_matrix.strategy.max-parallel to 2
Here’s why:
jobs.example_matrix.strategy.concurrency
is not a valid option for limiting concurrent jobs within a matrix.- While a matrix will attempt to run all jobs in parallel by default,
jobs.example_matrix.strategy.max-parallel
allows you to specify the maximum number of jobs that can run concurrently. Setting it to 2 will ensure only two jobs from your matrix execute at the same time. - Using the Github REST API is unnecessary for this purpose. The
max-parallel
option provides a built-in way to control concurrency within your workflow definition.
Q6: What is the default timeout for a GitHub Actions job?
360 minutes
30 minutes
60 minutes
120 minutes
Reveal Solution
The default timeout for a GitHub Actions job is 360 minutes (6 hours).
Q7: Are Github Actions free for public repositories?
No
Yes
Reveal Solution
Yes, GitHub Actions are free for public repositories.
Here’s why:
- GitHub offers a “pay-as-you-go” pricing model for Actions.
- Public repositories benefit from free usage of standard GitHub-hosted runners. This means you can automate your workflows without incurring any costs.
- Private repositories require paid plans for exceeding the free minutes allotment.
Q8: How can you override an organization-level GitHub Secret API_KEY
with a different value when working within a repository? (Select two.)
By creating a repository secret with the name REPOSITORY_API_KEY
By creating a repository secret with the same name API_KEY
By creating a environment secret with the name ENVIRONMENT_API_KEY
By creating a environment secret with the same name API_KEY
By creating a repository secret with the name OVERRIDE_API_KEY
By creating a enterprise secret with the same name API_KEY
By creating a environment secret with the name OVERRIDE_API_KEY
By creating a enterprise secret with the name OVERRIDE_API_KEY
Reveal Solution
There are two ways to override an organization-level GitHub Secret with a different value when working within a repository:
- Creating a repository secret with the same name (API_KEY)
- Creating an environment secret with the same name (API_KEY)
Here’s why these options work:
- Same name repository secret: When a secret name exists at both the organization and repository level, GitHub Actions prioritizes the repository-level secret. This allows you to have a default value for the organization but override it for specific needs within a repository.
- Environment secret: While environment secrets are typically used for different values across environments (staging, production), they can also be used to override organization secrets within a repository. Similar to repository secrets, environment secrets take precedence over organization secrets if they share the same name.
Q10: Which of the following are default environment variables in GitHub Actions? (Select three.)
GITHUB_WORKFLOW
GITHUB_USER
GITHUB_ORGANIZATION
GITHUB_TOKEN
GITHUB_REPOSITORY
GITHUB_ACTOR
Reveal Solution
There are three default environment variables in GitHub Actions:
- GITHUB_WORKFLOW
- GITHUB_REPOSITORY
- GITHUB_ACTOR
Here’s why the other options are not default environment variables:
- GITHUB_USER: This variable is not provided by default. It might be available in specific contexts or custom setups.
- GITHUB_ORGANIZATION: Similar to
GITHUB_USER
, this is not a default variable but could be available depending on the workflow context. - GITHUB_TOKEN: This is a sensitive token that provides elevated access and is not exposed by default for security reasons. You can access a limited-permission token using secrets or environment variables, but it won’t be identical to the full token.
Q11: How can organizations which are using GitHub Enterprise Server enable automatic syncing of third party GitHub Actions hosted on GitHub.com to their GitHub Enterprise Server instance?
GitHub Enterprise Server cannot use GitHub.com Actions because of it's on-premise nature and no internet access.
Using actions-sync tool
GitHub Enterprise Server has access to all GitHub.com Actions by default
Using GitHub Connect
Reveal Solution
The correct answer is: Using GitHub Connect
Here’s why:
- GitHub Enterprise Server limitations: While GitHub Enterprise Server can’t directly access GitHub.com Actions due to its on-premise nature and potential lack of internet access, GitHub Connect bridges this gap.
- actions-sync tool: This tool is helpful for manually syncing actions from GitHub.com to a limited set of actions, but it’s not suitable for automatic syncing of a large collection of third-party actions.
- Default access: By default, GitHub Enterprise Server instances don’t have automatic access to all GitHub.com Actions.