GitHub Actions Practice Exam, Exams of Technology

Focuses on automating workflows with GitHub Actions. Topics: YAML syntax, workflows, jobs, runners, CI/CD, secrets management, and integrating testing/deployment pipelines.

Typology: Exams

2024/2025

Available from 08/29/2025

BookVenture
BookVenture 🇮🇳

3.2

(20)

26K documents

1 / 175

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
GitHub Actions Exam
Question 1. In a GitHub Actions workflow YAML file, which top-level key
defines the event(s) that trigger the workflow?
A) jobs
B) name
C) on
D) steps
Answer: C
Explanation: The on key specifies the GitHub events that trigger the
workflow, such as push, pull_request, or schedule.
Question 2. Which context would you use to access the SHA of the
current commit in a workflow?
A) env
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download GitHub Actions Practice Exam and more Exams Technology in PDF only on Docsity!

Question 1. In a GitHub Actions workflow YAML file, which top-level key defines the event(s) that trigger the workflow? A) jobs B) name C) on D) steps Answer: C Explanation: The on key specifies the GitHub events that trigger the workflow, such as push, pull_request, or schedule. Question 2. Which context would you use to access the SHA of the current commit in a workflow? A) env

B) github C) runner D) job Answer: B Explanation: github.sha provides the commit SHA; github is the context for information about the workflow run and repository. Question 3. How do you define a secret in a GitHub Actions workflow? A) Using the env key B) Using the secrets context C) Defining under jobs D) Using the outputs key Answer: B

Question 5. Where should workflow YAML files be stored in a repository? A) /.github/actions B) /workflows C) /.github/workflows D) /ci Answer: C Explanation: Workflow files must be placed in the .github/workflows directory for GitHub Actions to recognize them. Question 6. Which syntax allows you to conditionally run a step only if the previous step failed? A) if: success() B) if: always()

C) if: failure() D) if: cancelled() Answer: C Explanation: if: failure() ensures the step runs only if the previous one failed. Question 7. What is the correct way to define a job matrix to test across multiple Node.js versions? A) matrix: node-version: [12, 14, 16] B) strategy: matrix: node-version: [12, 14, 16] C) jobs: matrix: node-version: [12, 14, 16] D) matrix: [12, 14, 16] Answer: B

Question 9. How do you reference an output from a previous job in a subsequent job? A) needs.job_id.outputs.output_name B) steps.output_name C) outputs.job_id.output_name D) job_id.outputs.output_name Answer: A Explanation: Use needs.job_id.outputs.output_name to reference outputs from previous jobs. Question 10. What is the main purpose of the needs keyword in a job definition? A) Specifies environment variables B) Defines job dependencies

C) Sets job concurrency D) Registers artifacts Answer: B Explanation: needs defines the jobs that must complete before the current job runs, setting dependencies. Question 11. Which of the following is NOT a valid GitHub Actions event? A) push B) issue_comment C) merge D) repository_dispatch Answer: C

Question 13. Which key is used to define inputs for a reusable workflow? A) with B) inputs C) parameters D) arguments Answer: B Explanation: The inputs key defines input parameters for reusable workflows. Question 14. If you want to prevent two workflow runs from executing at the same time, which feature should you use? A) needs B) matrix

C) concurrency D) outputs Answer: C Explanation: The concurrency key is used to ensure only one workflow run executes at a time for a given group. Question 15. In which context would you find the name of the runner’s operating system? A) github B) runner C) env D) job Answer: B

A) on: [pull_request] B) on: pull_request: branches: [branch_name] C) on: pull_request_branch: [branch_name] D) on: branches: [branch_name] Answer: B Explanation: The correct syntax is on: pull_request: branches: [branch_name] to limit to specific branches. Question 18. Where do you define the runs-on key in a workflow file? A) At the workflow level B) At the job level C) At the step level D) At the action level

Answer: B Explanation: runs-on is specified under each job to define the environment for that job. Question 19. Which of the following is a built-in GitHub Actions runner? A) ubuntu-latest B) windows-server- 2019 C) macOS-latest D) All of the above Answer: D Explanation: GitHub Actions provides runners for Ubuntu, Windows, and macOS.

C) Add logging: debug to job D) Use debug() expression Answer: B Explanation: Setting the ACTIONS_STEP_DEBUG secret to true enables step debug logging. Question 22. What is the function of the uses keyword in a workflow step? A) Defines a shell command B) Specifies an action to use C) Assigns environment variables D) Sets job dependencies Answer: B

Explanation: uses specifies an action or reusable workflow to use in the step. Question 23. Which of the following is a valid way to specify an action version? A) uses: actions/checkout B) uses: actions/checkout@v C) uses: actions/checkout:v D) uses: actions/checkout#v Answer: B Explanation: actions/checkout@v2 pins the action to version 2. Question 24. What is the recommended strategy for using third-party actions securely?

D) With artifacts Answer: C Explanation: Environment variables are used to share data between steps in the same job. Question 26. Which of these is NOT a valid context in GitHub Actions? A) github B) runner C) workflows D) secrets Answer: C Explanation: workflows is not a context; valid contexts include github, runner, env, secrets, etc.

Question 27. What is the purpose of the GITHUB_TOKEN in a workflow? A) To authenticate with external APIs B) To authenticate on behalf of GitHub Actions for API calls C) To store workflow secrets D) To cache dependencies Answer: B Explanation: GITHUB_TOKEN allows workflows to authenticate as the GitHub Actions app for automated API calls. Question 28. How can you run a job only when a specific file changes? A) Use paths in on B) Use needs