Files
portfolio/.githooks
denshooter 5a14efb5fc
Some checks failed
CI/CD Pipeline (Simple) / test-and-build (push) Has been skipped
CI/CD Pipeline (Simple) / production (push) Failing after 7m53s
Make Docker mandatory for pre-push hook
- Docker must be running and functional before push is allowed
- Added comprehensive Docker status checks (info + hello-world test)
- Enhanced error messages with platform-specific Docker start instructions
- Improved build error reporting with detailed log output
- Added common troubleshooting tips for Docker build failures
- Push will fail if Docker is not available or build fails
2025-09-12 23:36:42 +02:00
..
2025-09-12 23:31:46 +02:00

Git Hooks

This directory contains Git hooks for the Portfolio project.

Pre-Push Hook

The pre-push hook runs automatically before every git push and performs the following checks:

Checks Performed:

  1. Node.js Version Check - Ensures Node.js 20+ is installed
  2. Dependency Installation - Installs npm dependencies if needed
  3. Linting - Runs ESLint to check code quality
  4. Tests - Runs Jest test suite
  5. Build - Builds the Next.js application
  6. Security Audit - Runs npm audit for vulnerabilities
  7. Secret Detection - Checks for accidentally committed secrets
  8. Docker Configuration - Validates Dockerfile and docker-compose.yml
  9. Production Checks - Additional checks when pushing to production branch

Production Branch Special Checks:

  • Environment file validation
  • Docker build test
  • Deployment readiness check

Usage:

The hook runs automatically on every push. To manually test it:

# Test the hook manually
.githooks/pre-push

# Or push to trigger it
git push origin main

Bypassing the Hook:

If you need to bypass the hook in an emergency:

git push --no-verify origin main

Note: Only bypass in emergencies. The hook prevents broken code from being pushed.

Troubleshooting:

If the hook fails:

  1. Fix the reported issues (linting errors, test failures, etc.)
  2. Run the checks manually to debug:
    npm run lint
    npm run test
    npm run build
    npm audit
    
  3. Check Node.js version: node --version (should be 20+)
  4. Reinstall dependencies: rm -rf node_modules && npm ci

Configuration:

The hook is configured in .git/config:

[core]
    hooksPath = .githooks

To disable hooks temporarily:

git config core.hooksPath ""

To re-enable:

git config core.hooksPath .githooks