#!/bin/bash # Pre-push hook to generate PDFs before pushing # This ensures PDFs are always up to date when code is pushed set -e REPO_ROOT="$(git rev-parse --show-toplevel)" DOCKER_DIR="$REPO_ROOT/docker" PDFS_DIR="$REPO_ROOT/docker/resume/pdfs" echo "Running pre-push hook: Generating PDFs..." # Navigate to docker directory cd "$DOCKER_DIR" # Check if node_modules exists, install if not if [ ! -d "node_modules" ]; then echo "Installing npm dependencies..." npm install fi # Generate PDFs echo "Generating PDFs..." if npm run generate-pdfs; then echo "✓ PDFs generated successfully" # Stage the PDFs directory if it exists and has changes cd "$REPO_ROOT" if [ -d "$PDFS_DIR" ]; then # Check if there are any PDF files if [ -n "$(find "$PDFS_DIR" -name "*.pdf" -type f 2>/dev/null)" ]; then # Add PDFs to staging git add "$PDFS_DIR"/*.pdf 2>/dev/null || true # Check if there are unstaged changes if ! git diff --cached --quiet --exit-code "$PDFS_DIR" 2>/dev/null; then echo "PDFs updated and staged" fi fi fi else echo "✗ PDF generation failed" exit 1 fi exit 0