GitHub Actions is a tool that helps you automate tasks in your software projects, like testing code or deploying apps, by running scripts when certain events happen.
Click to reveal answer
beginner
What file defines a GitHub Actions workflow?
A workflow is defined in a YAML file located in the .github/workflows/ folder of your repository.
Click to reveal answer
beginner
What triggers can start a GitHub Actions workflow?
Workflows can start on events like pushing code, opening a pull request, or on a schedule.
Click to reveal answer
beginner
What is a job in GitHub Actions?
A job is a set of steps that run on the same machine. Jobs can run sequentially or at the same time.
Click to reveal answer
beginner
How do you specify the operating system for a job in GitHub Actions?
You use the runs-on key in the job to choose the OS, like ubuntu-latest or windows-latest.
Click to reveal answer
Where do you place the workflow YAML files in a GitHub repository?
Aroot/
B.github/workflows/
Csrc/workflows/
Ddocs/
✗ Incorrect
Workflow files must be inside the .github/workflows/ folder to be recognized by GitHub Actions.
Which event can trigger a GitHub Actions workflow?
Apush
Bemail received
Cfile downloaded
Dscreen unlocked
✗ Incorrect
GitHub Actions workflows can be triggered by events like push, pull_request, or schedule, but not external events like email.
What does the runs-on key specify in a job?
AThe repository branch
BThe programming language used
CThe operating system where the job runs
DThe user who runs the job
✗ Incorrect
runs-on tells GitHub Actions which OS to use for running the job.
What is a step in a GitHub Actions job?
AA single task or command executed in the job
BA branch in the repository
CA user who approves the workflow
DA file in the repo
✗ Incorrect
Steps are individual commands or actions that run inside a job.
Can multiple jobs in a workflow run at the same time?
AOnly if triggered by different events
BNo, jobs always run one after another
COnly if they use the same OS
DYes, jobs can run in parallel
✗ Incorrect
Jobs can run in parallel unless you set dependencies between them.
Explain how a GitHub Actions workflow is structured and triggered.
Think about where the file lives, what starts it, and what it contains.
You got /4 concepts.
Describe the difference between a job and a step in GitHub Actions.
Consider how tasks are grouped and executed.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of GitHub Actions in a repository?
easy
A. To automate tasks like testing and deployment when events happen
B. To store large files in the repository
C. To manage user permissions on the repository
D. To create branches automatically
Solution
Step 1: Understand GitHub Actions role
GitHub Actions automate workflows triggered by events such as code pushes or pull requests.
Step 2: Compare options with purpose
Options B, C, and D describe other GitHub features, not automation tasks.
Final Answer:
To automate tasks like testing and deployment when events happen -> Option A
Quick Check:
Automation = A [OK]
Hint: GitHub Actions = automation triggered by events [OK]
Common Mistakes:
Confusing GitHub Actions with file storage
Thinking it manages user permissions
Assuming it creates branches automatically
2. Which of the following is the correct location to place a GitHub Actions workflow file?
easy
A. .git/actions/
B. .github/workflows/
C. workflows/.github/
D. actions/workflows/
Solution
Step 1: Recall workflow file location
GitHub Actions workflows must be stored in the .github/workflows/ directory in the repository.
Step 2: Verify other options
Options B, C, and D do not match the required directory structure for workflows.
Final Answer:
.github/workflows/ -> Option B
Quick Check:
Workflow path = .github/workflows/ [OK]
Hint: Workflow YAML files go inside .github/workflows/ folder [OK]
Common Mistakes:
Placing workflow files outside .github/workflows/
Using incorrect folder names like .git or actions
Confusing workflows folder location
3. Given this workflow snippet, what will happen when code is pushed to the main branch?
name: Test Workflow
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "Build started"
medium
A. The workflow runs and prints 'Build started' on push to main
B. The workflow runs but does nothing on push to main
C. The workflow runs only on pull requests, not push
D. The workflow fails due to syntax error
Solution
Step 1: Analyze trigger event
The workflow triggers on push events to the main branch as specified under 'on: push: branches: - main'.
Step 2: Check job steps
The job named 'build' runs on ubuntu-latest and executes a step that runs the command echo "Build started".
Final Answer:
The workflow runs and prints 'Build started' on push to main -> Option A
Quick Check:
Push to main triggers echo output [OK]
Hint: Push to main triggers echo command in workflow [OK]
Common Mistakes:
Thinking workflow triggers on pull requests only
Assuming no output is printed
Believing there is a syntax error
4. Identify the error in this workflow YAML:
name: CI
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Run tests
run: pytest
- name: Deploy
run: deploy.sh
if: success()
medium
A. The 'if' condition syntax is incorrect; should be 'if: success()' without indentation
B. The 'steps' list is missing a dash before 'Deploy'
C. The 'if' condition is invalid; it should be 'if: ${{ success() }}'
D. The 'runs-on' key is misspelled
Solution
Step 1: Review 'if' condition syntax in GitHub Actions
GitHub Actions requires expressions inside ${{ }} for conditions, so 'if: success()' is invalid syntax.
Step 2: Validate other parts
'runs-on' is correctly spelled, and the steps list has proper dashes. Indentation is correct.
Final Answer:
The 'if' condition is invalid; it should be 'if: ${{ success() }}' -> Option C
Quick Check:
Conditions need ${{ }} syntax [OK]
Hint: Use ${{ }} for conditions in GitHub Actions [OK]
Common Mistakes:
Omitting ${{ }} around conditions
Misplacing dashes in steps list
Misspelling 'runs-on'
5. You want a GitHub Actions workflow that runs tests only when code is pushed to the 'develop' branch or when a pull request targets 'develop'. Which 'on' configuration is correct?
hard
A. on:
push:
branches:
- develop
pull_request:
branches:
- main
B. on:
push:
branches:
- main
pull_request:
branches:
- develop
C. on:
push:
branches:
- main
pull_request:
branches:
- main
D. on:
push:
branches:
- develop
pull_request:
branches:
- develop
Solution
Step 1: Understand event triggers needed
The workflow should trigger on push to 'develop' and on pull requests targeting 'develop'.
Step 2: Match branches in 'on' configuration
on:
push:
branches:
- develop
pull_request:
branches:
- develop correctly specifies both push and pull_request events with branches set to 'develop'. Other options mix 'main' and 'develop' incorrectly.
Final Answer:
on:
push:
branches:
- develop
pull_request:
branches:
- develop -> Option D
Quick Check:
Push and PR on develop branch = C [OK]
Hint: Match branch names exactly in push and pull_request triggers [OK]
Common Mistakes:
Mixing 'main' and 'develop' branches in triggers
Omitting pull_request event
Using incorrect indentation in YAML
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.