devops / ci-cd
CI/CD Pipelines: A GitHub Actions Workflow Explained Line by Line
One short, valid CI workflow, read a line at a time, then the free CI/CD services compared by what they actually give you. Action versions and free-tier numbers were checked against the providers' own pages in October 2026.
A CI/CD pipeline is a script that a server runs for you every time code changes: fetch the code, install dependencies, run the tests, and report pass or fail on the commit. Continuous integration is the habit of merging small changes often and letting that script check each one. Continuous delivery adds the guarantee that the main branch can be released at any moment, and continuous deployment goes one step further and releases every passing change without a human pressing a button. People searching for "free CI/CD" usually want two answers: what a working pipeline file looks like, and which service will run it without a bill. This page gives both, starting with the file.
01 · THE FILE
A complete CI workflow, line by line
This is a full workflow for a Node.js project. Save it as .github/workflows/ci.yml and GitHub runs it with no other setup. The YAML was parsed with a YAML library, and the action versions were taken from each action's releases page.
name: CI on: push: branches: [main] pull_request: permissions: contents: read jobs: test: runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: node-version: 22 cache: npm - run: npm ci - run: npm test
| Lines | What it does | Without it |
|---|---|---|
on: push (main) + pull_request | Runs the job when main changes and when a pull request is opened or updated | With only push, a broken change is found after it merges. With only pull_request, nothing re-checks main after the merge. |
permissions: contents: read | Limits the automatic GITHUB_TOKEN to reading the repository | The token keeps whatever default your repository settings grant, which is usually more than a test job needs |
runs-on: ubuntu-latest | Picks a fresh GitHub-hosted Linux virtual machine | Required: a job with no runner never starts |
timeout-minutes: 10 | Cancels a hung job after 10 minutes | GitHub's default is 360 minutes, so a stuck test can burn six hours of your quota |
actions/checkout | Copies your repository onto the runner | The runner starts empty, so npm ci finds no package.json and fails |
actions/setup-node with cache: npm | Installs Node 22 and restores npm's download cache between runs | Every run re-downloads every package, which adds time to every check |
npm ci | Installs exactly what package-lock.json lists | With npm install the lockfile can be rewritten mid-run, so the pipeline may test different versions than you do locally |
npm test | Runs the test script; a non-zero exit code fails the step and the job | You have a build server that never tells you anything |
Two details in that table are worth confirming from the source. GitHub's workflow syntax reference gives 360 as the default for timeout-minutes. And the npm documentation says npm ci exits with an error if the lockfile and package.json disagree, instead of updating the lockfile. That error is the point: it turns "works on my machine" into a failed check.
02 · WHAT A RUN PRODUCES
From a red check to a blocked merge
Every run attaches a status to the commit: a yellow dot while it runs, a green check when every step exits with zero, a red cross when any step does not. On a pull request that status shows next to the merge button. The check alone only informs people. To make it a gate, mark the job as a required status check in a branch protection rule; GitHub's documentation says that once a check is required, all required checks must pass before changes can be merged into the protected branch.
When a run fails, open the failed step first, not the whole log. The first red step names the cause; later steps are skipped by default after a failure, so they carry no information. Re-run only after reading why it failed. A pipeline that gets re-run until it goes green is hiding a flaky test, not proving the code works.
03 · WHO RUNS IT FOR FREE
Free CI/CD services compared
"Free" means different things here: free for public repositories, a monthly allowance for private ones, or free software that you host yourself. Numbers below come from each provider's own pricing or billing page.
| Service | What the free option gives you | Where the cost shows up |
|---|---|---|
| GitHub Actions | Standard GitHub-hosted runners are free in public repositories. The GitHub Free plan includes $12 of compute usage per month for private repositories, which is 2,000 minutes on a 2-core Linux runner at $0.006 per minute. | Usage past the included amount is billed to the repository owner. A 2-core Windows runner is $0.010 per minute and a macOS runner is $0.062. |
| GitLab CI/CD | The Free tier lists 400 compute minutes per month. | The next tier up lists 10,000 compute minutes per month. |
| CircleCI | The Free plan lists up to 6,000 build minutes and up to 5 active users. | Paid plans start at $15 per month and run on credits. |
| Jenkins | MIT-licensed software with no usage limit. | You provide and maintain the server it runs on, including updates and security patches. |
GitHub now states the included allowance as a dollar amount rather than a fixed number of minutes, so the 2,000-minute figure is our arithmetic ($12 divided by $0.006), not a number GitHub promises. Pick GitHub Actions if your code is already on GitHub; the workflow file above is all you need. Pick GitLab CI if your code lives there. Choose Jenkins when you must run on your own hardware, and expect to spend real time on upkeep.
04 · THE SAFETY LAYER
Tags, tokens and secrets: the pipeline is code that holds keys
A workflow runs other people's code, the actions, with access to your repository and sometimes your deploy credentials. In March 2025 the widely used tj-actions/changed-files action was compromised (CVE-2025-30066), and CISA's alert says the compromise allowed disclosure of secrets including access keys, personal access tokens and npm tokens. Workflows that referenced the action by a movable tag picked up the bad version.
- Pin third-party actions to a full commit SHA. GitHub's secure-use guide recommends it, because an attacker would need a SHA-1 collision to swap the code behind a SHA. First-party
actions/*tags like the ones above are a lower risk but the same logic applies. - Keep
GITHUB_TOKENread-only by default and raise permissions per job, as GitHub's guidance suggests. - Store credentials as secrets and reference them by name; never write them into the YAML.
::add-mask::, and it warns that secrets printed through some workarounds are not redacted. Treat any credential that has appeared in a log or a commit as compromised and rotate it. The full pipeline-security picture, including scanners and supply-chain attestations, is on the DevSecOps page.05 · SOURCES
References worth reading in full
Official references for the three big platforms. Read the one you will use; the concepts carry across.
- Quickstart for GitHub Actions ↗GitHub's own first workflow, added through the web interface. A good companion to the file above.docs.github.com
- Workflow syntax for GitHub Actions ↗The reference for every key used above, including
permissionsandtimeout-minutes.docs.github.com - Secure use reference ↗Pinning actions, token permissions and script-injection risks, from GitHub.docs.github.com
- Tutorial: Create and run your first GitLab CI/CD pipeline ↗The same idea in GitLab's
.gitlab-ci.ymlformat.docs.gitlab.com - Jenkins Pipeline ↗How a Jenkinsfile describes stages and steps, from the Jenkins handbook.jenkins.io
The practice behind the tools. These two explain why a team runs a pipeline and how to tell whether it is working.
- Continuous Integration by Martin Fowler ↗The long-form essay on what CI requires of a team, beyond running a build server.martinfowler.com
- DORA's software delivery performance metrics ↗Change lead time, deployment frequency, failed deployment recovery time, change fail rate and deployment rework rate: the measures a pipeline should improve.dora.dev
06 · PRACTICE
Make the pipeline fail on purpose
07 · FAQ
Frequently asked questions
Is GitHub Actions free?
Standard GitHub-hosted runners are free in public repositories, and self-hosted runners are free to use. For private repositories, the GitHub Free plan includes $12 of compute usage per month, and extra usage is billed to the repository owner. GitHub states the allowance as money rather than minutes.
What is the difference between continuous delivery and continuous deployment?
Continuous delivery means every passing change is ready to release, and a person decides when to release it. Continuous deployment removes that decision: every change that passes the pipeline goes to production automatically.
Why use npm ci instead of npm install in a pipeline?
npm ci installs exactly what the lockfile lists and exits with an error if the lockfile and package.json disagree. npm install can update the lockfile, so a pipeline using it may test different dependency versions than you have locally.
Should I pin GitHub Actions to a tag or a commit SHA?
GitHub recommends pinning third-party actions to a full-length commit SHA, because tags can be moved. Pin to a tag only if you trust the action's creator. The 2025 tj-actions/changed-files compromise is the standard example of why.
Which CI/CD tool should I learn first?
Start with the one that sits next to your code. GitHub Actions for GitHub repositories, GitLab CI/CD for GitLab. The ideas are the same everywhere: a trigger, a clean machine, ordered steps and an exit code. Jenkins is worth learning if your employer already runs it.