-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-push
More file actions
executable file
Β·42 lines (34 loc) Β· 1.41 KB
/
.pre-push
File metadata and controls
executable file
Β·42 lines (34 loc) Β· 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# Pre-push hook to run local GitHub Actions before pushing to remote
# This prevents failed CI builds on GitHub
protected_branch='main'
current_branch=$(git symbolic-ref HEAD | sed 's!refs\/heads\/!!')
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}π Pre-push hook: Testing locally before push${NC}"
# Only run on main branch pushes (or configure as needed)
if [[ "$current_branch" == "$protected_branch" ]]; then
echo -e "${YELLOW}π Running local CI for protected branch: $protected_branch${NC}"
# Run our local CI script
if [[ -f "scripts/test-local-ci.sh" ]]; then
echo -e "${BLUE}π Running local GitHub Actions...${NC}"
# Run local CI testing
if ! bash scripts/test-local-ci.sh ci; then
echo -e "${RED}β Local CI failed! Push blocked.${NC}"
echo -e "${YELLOW}π‘ Fix the issues and try pushing again${NC}"
echo -e "${YELLOW}π‘ Or run: ./scripts/test-local-ci.sh${NC}"
exit 1
fi
echo -e "${GREEN}β
Local CI passed! Proceeding with push...${NC}"
else
echo -e "${YELLOW}β οΈ Local CI script not found, skipping local tests${NC}"
fi
else
echo -e "${YELLOW}π Non-protected branch ($current_branch), skipping local CI${NC}"
fi
echo -e "${GREEN}β
Pre-push hook completed successfully${NC}"
exit 0