GitHub Actions
devopsgithub-actionsGuideIntermediate
GitHub Actions Pull Request Checks & Branch Protection
Build robust pull request validation pipelines, status checks, automated testing, and enforce merge gates using GitHub branch protection rules.
Verified: 2026-10-01
Tested on:github-actions current
Platforms:
all
#github-actions#pull-requests#branch-protection#testing#quality
GitHub Actions Pull Request Checks & Branch Protection
Automated Pull Request (PR) checks ensure that no broken code, syntax errors, or failing tests are ever merged into your default branch (main).
1. Standard Pull Request CI Workflow
name: Pull Request CI
on:
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: pr-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
validate:
name: Code Quality & Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout PR Branch
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Run ESLint
run: pnpm lint
- name: Run TypeScript Type Check
run: pnpm typecheck
- name: Run Unit Tests
run: pnpm test2. Enforcing Branch Protection Rules
To block merging when CI checks fail:
- Navigate to Repository Settings -> Branches -> Add branch protection rule (or Rulesets).
- Set Branch name pattern to
main. - Check Require status checks to pass before merging.
- Search and select your job name:
Code Quality & Unit Tests. - Check Require branches to be up to date before merging.
- Check Do not allow bypassing the above settings.
GitHub Actions Environments & Deployments
Configure staging and production environments, manual approval protection rules, deployment branches, and environment URLs in GitHub Actions.
Practical GitHub Actions CI/CD Workflows
Production-ready, copy-paste GitHub Actions workflow examples for Next.js, Node.js lint/typecheck/test, Docker build & push, and SSH VPS deployments.