GitHub Actions runs automated workflows on push, pull request, or schedule. Each workflow is a YAML file in .github/workflows/. Today you will write your first workflow and understand jobs, steps, and runners.
# .github/workflows/hello.yml
name: Hello World
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
greet:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Print greeting
run: echo "Hello from GitHub Actions!"
- name: Show runner info
run: |
echo "OS: $RUNNER_OS"
echo "Workspace: $GITHUB_WORKSPACE"
node --version
python3 --version# Matrix build — test on multiple Node versions
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm teston key controls triggers. Use workflow_dispatch to add a manual run button in the GitHub UI.