GitHub Actions
Run tests automatically on every pull request and protect main.
What you will be able to do
- Read a workflow file
- Understand triggers, jobs and steps
- Keep secrets out of logs
GitHub Actions runs workflows from .github/workflows. A workflow listens for events, runs jobs on a runner and executes steps such as installing dependencies and testing.
name: CI
on:
pull_request:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm test| Concept | Purpose |
|---|---|
| on | Events that trigger the workflow |
| jobs | Independent work run on a runner |
| steps | Commands and reusable actions in order |
| secrets | Encrypted values injected at runtime |
| branch protection | Require checks before merging |
Your turn
EasyAdd a lint step
Extend the CI workflow so lint runs after dependencies are installed and before tests.
BASH · starter
- run: npm ci
- run: npm testCheck your understanding before moving on.
Knowledge checkQuestion 1
Where does a GitHub Actions workflow live?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.