// GitOps workflow automation for trunk-based development, branch strategy, release management, and deployment patterns. Use when setting up repositories, planning release strategies, or configuring CI/CD pipelines.
| name | gitops |
| description | GitOps workflow automation for trunk-based development, branch strategy, release management, and deployment patterns. Use when setting up repositories, planning release strategies, or configuring CI/CD pipelines. |
Purpose: Enforce GitOps best practices for trunk-based development, branch hygiene, release management, and deployment automation.
Activation: When user asks about branch strategy, release workflow, deployment patterns, or CI/CD setup.
| Branch | Purpose | Protection |
|---|---|---|
main | Production-ready code | PR required, status checks |
develop | Integration branch | PR required, status checks |
feature/* | New features | Short-lived (<1 week) |
fix/* | Bug fixes | Short-lived (<3 days) |
release/* | Release preparation | Protected during release |
CRITICAL: Use all-lowercase names only.
Cross-platform teams (Windows/macOS/Linux) experience case-sensitivity bugs:
Dev/Feature ≠ dev/featureDev/Feature = dev/featurefeature/user-authentication # New features
fix/login-redirect-issue # Bug fixes
refactor/api-client # Code improvements
docs/readme-update # Documentation
test/contract-signing # Test additions
chore/dependency-update # Maintenance
release/v1.2.0 # Release preparation
hotfix/critical-security # Production hotfixes
Never use: Feature/UserAuth, Dev/DemoData, Fix/Login-Issue
feature/xyz --> develop --> main --> production
| | |
v v v
(dev) (staging) (production)
git checkout develop
git pull origin develop
git checkout -b feature/my-feature
# Make changes, commit frequently
git add -A
git commit -m "feat: implement feature X"
# Keep branch up to date
git fetch origin
git rebase origin/develop
# Push and create PR
git push -u origin feature/my-feature
gh pr create --base develop
git checkout develop
git pull origin develop
git checkout -b release/v1.2.0
# Version bump, changelog
npm version minor
# Create release PR to main
gh pr create --base main --title "Release v1.2.0"
# After merge, tag the release
git checkout main
git pull origin main
git tag -a v1.2.0 -m "Release v1.2.0"
git push origin v1.2.0
# Back-merge to develop
git checkout develop
git merge main
git push origin develop
git checkout main
git checkout -b hotfix/critical-fix
# Apply fix
git commit -m "fix: critical security patch"
# PR to main (expedited review)
gh pr create --base main --title "HOTFIX: Critical security patch"
# After merge, back-merge to develop
git checkout develop
git merge main
git push origin develop
main:
require_pull_request_reviews:
required_approving_review_count: 1
dismiss_stale_reviews: true
require_status_checks:
strict: true
contexts:
- build
- test
- lint
enforce_admins: true
require_linear_history: true
develop:
require_pull_request_reviews:
required_approving_review_count: 1
require_status_checks:
strict: false
contexts:
- build
- test
gh api repos/{owner}/{repo}/branches/main/protection \
-X PUT \
-H "Accept: application/vnd.github+json" \
-f required_status_checks='{"strict":true,"contexts":["build","test"]}' \
-f enforce_admins=true \
-f required_linear_history=true \
-f required_pull_request_reviews='{"required_approving_review_count":1}'
# Fetch and prune stale references
git fetch --prune
# Delete merged local branches
git branch --merged main | rg -v '^\*|main|develop' | xargs git branch -d
# Delete merged remote branches
git branch -r --merged origin/main | rg -v 'main|develop|HEAD' | \
sed 's/origin\///' | xargs -I {} git push origin --delete {}
# Enable auto-prune
git config --global fetch.prune true
name: Branch Cleanup
on:
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete stale branches
uses: beatlabs/delete-old-branches-action@v0.0.10
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
date: '30 days ago'
dry_run: false
exclude_branches: 'main,develop,release/*'
develop --> staging --> production
| | |
v v v
PR merge Tag v1.x.x Tag v1.x.x
{
"git": {
"deploymentEnabled": {
"main": true,
"develop": true
}
},
"branch": {
"main": "production",
"develop": "preview"
}
}
on:
push:
branches: [main]
tags: ['v*']
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}
steps:
- uses: actions/checkout@v4
- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: ${{ github.ref == 'refs/heads/main' && '--prod' || '' }}
type: brief description
[optional body]
Primary Author: Your Name
| Type | Description |
|---|---|
| feat | New feature |
| fix | Bug fix |
| docs | Documentation |
| style | Formatting (no code change) |
| refactor | Code restructuring |
| test | Adding tests |
| chore | Maintenance |
| perf | Performance improvement |
# Install commitlint
npm install -D @commitlint/cli @commitlint/config-conventional
# Create config
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js
# Add Husky hook
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
echo "=== Branch State ==="
git branch -a | wc -l
echo "branches total"
echo "=== Merged Branches ==="
git branch --merged main | wc -l
echo "merged into main"
echo "=== Stale Tracking ==="
git branch -vv | rg ': gone]' | wc -l
echo "stale tracking refs"
echo "=== Last Activity ==="
git for-each-ref --sort=-committerdate refs/heads/ \
--format='%(committerdate:relative) %(refname:short)' | head -10
Never use these characters in filenames:
< > : " / \ | ? *
Why: Windows cannot create files with these characters. Git repos with such files will fail to clone/checkout on Windows with "Invalid argument" errors.
Example: V>>_PATTERNS.md works on macOS/Linux but breaks on Windows.
These names are reserved and cannot be used (with any extension):
CON, PRN, AUX, NUL
COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9
Example: aux.md, COM1.txt, nul.json are all invalid on Windows.
For cross-platform teams, use only:
Combines with:
branch-cleanup - Detailed branch pruningpr-automation - PR creation workflowgithub-actions-setup - CI/CD configurationv1.1 (2025-12-01)
v1.0 (2025-12-01)