Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know the building blocks
Event → workflow → jobs → steps.
| Part | Meaning |
|---|---|
| Workflow | A YAML file in .github/workflows/ |
| Event | What starts it: push, pull request, schedule, manual |
| Job | A group of steps on one runner; jobs run in parallel by default |
| Step | One shell command (run) or one action (uses) |
| Runner | The machine: GitHub-hosted (ubuntu-latest, windows-latest, macos-latest) or self-hosted |
| Action | A reusable step from the Marketplace or your own repository |
Write a workflow
The smallest useful workflow: on every push, check out the code and run a test.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Show the tools
run: |
uname -a
python3 --version
- name: Run the tests
run: ./scripts/test.shmkdir -p .github/workflows
git add .github/workflows/ci.yml
git commit -m "Add CI workflow"
git push
gh run list
gh run watch
gh run view --log-failedOnthoud
Indentation is part of YAML. Use spaces, never tabs. A wrong indent is the most common error.
Chain jobs
Jobs run in parallel. needs makes a job wait for others — build, then test, then deploy.
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make build
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make test
deploy:
needs: [build, test]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- run: echo "deploy"Choose a runner
GitHub-hosted runners are new, clean VMs for every job. Self-hosted runners are your own machines — for private networks or special hardware.
| Runner | Good | Watch out |
|---|---|---|
| GitHub-hosted | Clean every time, no maintenance | Minutes limits on private repos |
| Self-hosted | Reach private networks, own tools, no minute cost | You patch and secure them; never use them for public repos |
| Larger runners | More CPU/RAM, static IPs | Cost |
Read the results
Every run shows its jobs and the log of every step in the Actions tab, and as checks on the commit or pull request.
- A red X on a pull request = a failed check; click Details for the log.
- Re-run failed jobs after a flaky failure.
- Add a badge to the README:
.