YAML that becomes your CI
A GitHub Actions workflow lives at .github/workflows/<name>.yaml. It declares when to run (events), where to run (runner), and what to run (steps). Three nesting levels: workflow → jobs → steps.
The skeleton
on:— trigger events.push,pull_request,workflow_dispatch(manual),schedule(cron),workflow_call(reusable).jobs:— named jobs that run in parallel by default. Each job picks aruns-on:runner.steps:— ordered list within a job. Each step is eitheruses:(a published action) orrun:(a shell command).
Secrets and permissions
Secrets live at the repo or org level; reference as ${{ secrets.NAME }}. The default GITHUB_TOKEN has read-only contents permission since 2023; if you need writes (push tags, create releases), declare permissions: contents: write on the job.
The 'pin actions to SHAs' rule:
uses: actions/checkout@v4 tracks v4's moving tag. A compromised maintainer could ship malicious code under v4 and your CI runs it. For supply-chain safety, pin to a SHA: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11. Dependabot updates these automatically.