10 Cloud CI/CD Pipeline Templates for Beginners
10 copy-ready CI/CD pipeline templates for beginners: GitHub Actions, GitLab CI/CD, AWS CodeBuild, Azure Pipelines and Google Cloud Build, with notes.
A cloud CI/CD pipeline template is a ready-made YAML file that builds, tests and deploys code on a hosted service such as GitHub Actions, GitLab CI/CD, AWS CodeBuild, Azure Pipelines or Google Cloud Build. The 10 templates below are short, commented starting points for beginners, each with what it does, when to use it and what to change.
Copy one, commit it, watch it run, then change one thing at a time. If you have never set up a pipeline before, read 12 steps to implement CI/CD in your project first. For a comparison of platforms, see top 10 CI/CD tools.
Key takeaways
- Start with CI (build and test on every push and pull request) before adding deployment.
- Each platform has its own file location:
.github/workflows/*.yml,.gitlab-ci.yml,buildspec.yml,azure-pipelines.ymlandcloudbuild.yaml. - Use the platform's secret store or OIDC federation for credentials. Never put keys in YAML.
- Pin action and image versions so a template keeps working the same way.
- Run the cheapest checks first (lint, unit tests) so failures show up fast.
- The action versions in this post were checked against each project's GitHub releases page in November 2026. Check again before you copy.
The 10 templates at a glance
| # | Template | Platform | File | Good first project |
|---|---|---|---|---|
| 1 | Node.js CI | GitHub Actions | .github/workflows/ci.yml | Any JavaScript app |
| 2 | Python CI with a version matrix | GitHub Actions | .github/workflows/python.yml | Flask or Django app, library |
| 3 | Docker build and push to GHCR | GitHub Actions | .github/workflows/docker.yml | Any containerized app |
| 4 | Static site to GitHub Pages | GitHub Actions | .github/workflows/pages.yml | Portfolio or docs site |
| 5 | Terraform plan on pull requests | GitHub Actions | .github/workflows/terraform.yml | Learning infrastructure as code |
| 6 | Basic build, test, deploy stages | GitLab CI/CD | .gitlab-ci.yml | Any app on GitLab |
| 7 | Docker image to the GitLab registry | GitLab CI/CD | .gitlab-ci.yml | Containerized app on GitLab |
| 8 | Build spec for CodeBuild | AWS CodeBuild | buildspec.yml | App deployed on AWS |
| 9 | Node.js CI | Azure Pipelines | azure-pipelines.yml | App on Azure DevOps |
| 10 | Container build and deploy to Cloud Run | Google Cloud Build | cloudbuild.yaml | App on Google Cloud |
GitHub Actions templates
GitHub Actions reads every YAML file in .github/workflows/. A workflow has triggers (on), one or more jobs, and steps inside each job. Steps either run shell commands or use a published action. For more ready-made workflows, see top 15 GitHub Actions workflows.
1. Node.js CI
What it does: installs dependencies with a lockfile, lints, runs tests and builds on every push to main and every pull request.
name: ci
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run lint --if-present
- run: npm test
- run: npm run build --if-present
What to change: the Node.js version, and the script names if your package.json uses different ones. npm ci needs a committed package-lock.json. The permissions block gives the job's token read-only access, which is a safe default.
2. Python CI with a version matrix
What it does: runs the same tests on several Python versions in parallel, which is useful for libraries and for checking an upgrade.
name: python
on: [push, pull_request]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
- run: pip install -r requirements.txt
- run: pip install pytest ruff
- run: ruff check .
- run: pytest -q
Quote the version numbers. Unquoted, YAML can read a value like 3.10 as the number 3.1.
3. Docker build and push to GitHub Container Registry
What it does: builds an image on every push to main and pushes it to ghcr.io with a tag based on the commit SHA. It uses the built-in GITHUB_TOKEN, so you do not create any secret.
name: docker
on:
push:
branches: [main]
permissions:
contents: read
packages: write
jobs:
image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
Image names on GHCR must be lowercase. If your organization or repository name has capital letters, set the tag to a lowercase value. The cache lines reuse layers between runs; our post on speeding up Docker builds in CI/CD explains more options.
4. Static site to GitHub Pages
What it does: builds a static site and publishes it with the official Pages actions. In the repository settings, set Pages to deploy from GitHub Actions first.
name: pages
on:
push:
branches: [main]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
- uses: actions/upload-pages-artifact@v5
with:
path: ./dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
Change ./dist to your build output folder. For a plain HTML site, remove the Node.js steps and point path at the folder with your files.
5. Terraform plan on pull requests
What it does: checks formatting, validates configuration and runs terraform plan on every pull request, so reviewers see what would change before anyone applies it.
name: terraform
on:
pull_request:
paths:
- "infra/**"
permissions:
contents: read
id-token: write
jobs:
plan:
runs-on: ubuntu-latest
defaults:
run:
working-directory: infra
steps:
- uses: actions/checkout@v7
- uses: hashicorp/setup-terraform@v4
- run: terraform fmt -check
- run: terraform init -input=false
- run: terraform validate
- run: terraform plan -input=false -no-color
Plan needs credentials for your cloud provider and a remote state backend. Use OIDC federation (the id-token: write permission) with your cloud's official login action instead of storing access keys. Keep terraform apply out of beginner pipelines until you have reviews and protected environments in place.
GitLab CI/CD templates
GitLab reads .gitlab-ci.yml from the repository root. Jobs are grouped into stages that run in order; jobs in the same stage run in parallel. Our 15 GitLab CI/CD pipeline examples post goes further.
6. Basic build, test and deploy stages
stages:
- build
- test
- deploy
default:
image: node:22
cache:
key:
files:
- package-lock.json
paths:
- .npm/
build:
stage: build
script:
- npm ci --cache .npm --prefer-offline
- npm run build
artifacts:
paths:
- dist/
test:
stage: test
script:
- npm ci --cache .npm --prefer-offline
- npm test
deploy_staging:
stage: deploy
script:
- echo "Deploy dist/ to staging here"
environment:
name: staging
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
The rules block limits deployment to the default branch. Replace the echo line with your real deploy command, and store any credentials as masked, protected CI/CD variables in the project settings.
7. Docker image to the GitLab container registry
build_image:
stage: build
image: docker:27
services:
- docker:27-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
The CI_REGISTRY* variables are predefined by GitLab, so no extra secrets are needed. Docker-in-Docker requires a runner with privileged mode. GitLab.com hosted runners support it; on a self-managed runner, ask your administrator, or use a daemonless builder such as Buildah or Kaniko-style tools.
AWS CodeBuild template
8. buildspec.yml for CodeBuild
CodeBuild reads buildspec.yml from the repository root by default. It can run on its own or as the build stage of CodePipeline.
version: 0.2
phases:
install:
runtime-versions:
nodejs: 22
pre_build:
commands:
- npm ci
build:
commands:
- npm test
- npm run build
artifacts:
base-directory: dist
files:
- "**/*"
cache:
paths:
- "/root/.npm/**/*"
Which runtime versions are available depends on the CodeBuild image you choose; check the "Available runtimes" table in the CodeBuild documentation. The build's permissions come from its IAM service role, so give that role only what the build needs, such as write access to one artifact bucket.
Azure Pipelines template
9. Node.js CI on Azure Pipelines
trigger:
branches:
include:
- main
pr:
branches:
include:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: UseNode@1
inputs:
version: "22.x"
- script: npm ci
displayName: Install
- script: npm test
displayName: Test
- script: npm run build
displayName: Build
- task: PublishPipelineArtifact@1
inputs:
targetPath: dist
artifact: web
Commit this as azure-pipelines.yml and create a pipeline from it in Azure DevOps. The pr trigger applies to GitHub and Bitbucket repositories; for Azure Repos, pull request validation is set with branch policies instead.
Google Cloud Build template
10. Build a container and deploy to Cloud Run
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- -t
- asia-south1-docker.pkg.dev/$PROJECT_ID/apps/web:$SHORT_SHA
- .
- name: gcr.io/cloud-builders/docker
args:
- push
- asia-south1-docker.pkg.dev/$PROJECT_ID/apps/web:$SHORT_SHA
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
- run
- deploy
- web
- --image=asia-south1-docker.pkg.dev/$PROJECT_ID/apps/web:$SHORT_SHA
- --region=asia-south1
images:
- asia-south1-docker.pkg.dev/$PROJECT_ID/apps/web:$SHORT_SHA
This assumes an Artifact Registry Docker repository named apps in the Mumbai region (asia-south1). $SHORT_SHA is filled in when the build is started by a trigger connected to a repository. The Cloud Build service account needs permission to deploy to Cloud Run and to act as the service's runtime account.
How to adapt any template
- Run it unchanged on a sample project to see a green build.
- Replace the language setup and commands with your project's.
- Add caching once the pipeline works, then measure the time saved.
- Add a security step, such as dependency scanning or secret scanning.
- Add deployment to a staging environment, with manual approval for production. See approval gates in CI/CD.
Beginner mistakes to avoid
| Mistake | What happens | Fix |
|---|---|---|
| Wrong file path or name | Pipeline never starts | Check the exact location each platform expects |
| Tabs in YAML | Parse error | Use spaces; enable a YAML linter in your editor |
| Secrets written in the file | Credentials leak through Git history | Use the platform secret store, rotate any exposed key |
Unpinned latest images | Builds break without code changes | Pin versions or digests |
| Deploying from every branch | Test code reaches shared environments | Limit deploy jobs to the default branch |
| No lockfile | Different dependency versions per run | Commit package-lock.json or equivalent |
When a pipeline fails and the cause is not obvious, our list of common CI/CD pipeline failures and fixes is a good place to look.
Practising with guidance
Templates get you running; knowing why each line exists is what lets you debug them. Our GitLab training in Pune covers pipelines, runners, registries and deployments in hands-on labs, in the Kharadi classroom or live online.
FAQ
What is a CI/CD pipeline template?
It is a reusable configuration file that defines how code is built, tested and deployed on a CI/CD platform. You copy it into your repository and adjust the commands and settings for your project.
Which cloud CI/CD platform is easiest for beginners?
GitHub Actions and GitLab CI/CD are usually easiest because the pipeline lives next to your code and hosted runners are available without setting up servers. Pick the one that matches where your code is hosted.
Where do I put a GitHub Actions workflow file?
In the .github/workflows/ folder of your repository. Any file there with a .yml or .yaml extension is treated as a workflow.
How do I store passwords and keys in a pipeline?
Use the platform's secret or variable store, such as GitHub Actions secrets or GitLab CI/CD masked variables. For cloud access, prefer OIDC federation so no long-lived keys are stored at all.
Should a beginner pipeline deploy to production automatically?
No. Start with build and test, then add automatic deployment to staging. Add production deployment behind a manual approval once tests and reviews are reliable.
Why should I pin action and image versions?
Pinning keeps the pipeline behaving the same way over time. An unpinned image or action can change underneath you and break builds or introduce unexpected behavior.
Can I use the same template on GitHub and GitLab?
Not directly. The syntax differs between platforms, but the structure is similar: triggers, jobs or stages, and steps. Translating a template is a good exercise for learning both.
References
- GitHub Docs: Workflow syntax for GitHub Actions
- GitHub Docs: Custom workflows with GitHub Pages
- GitLab Docs: CI/CD YAML syntax reference
- GitLab Docs: Use Docker to build Docker images
- AWS CodeBuild: Build specification reference
- Microsoft Learn: Azure Pipelines YAML schema
- Google Cloud: Deploy to Cloud Run using Cloud Build
- HashiCorp: Automate Terraform with GitHub Actions
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0