-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush.sh
More file actions
executable file
·139 lines (117 loc) · 2.66 KB
/
push.sh
File metadata and controls
executable file
·139 lines (117 loc) · 2.66 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
REPO_URL="https://github.com/crissymoon/Live-CSS-Editor.git"
# Ensure we are in the project directory
cd "$(dirname "$0")"
echo "--- push.sh: working in $PWD"
echo "--- push.sh: remote $REPO_URL"
# Create .gitignore if it doesn't exist
if [ ! -f .gitignore ]; then
cat > .gitignore << 'EOF'
# Environment and secrets
.env
.env.*
*.env
secrets.*
config.local.*
# macOS
.DS_Store
.AppleDouble
.LSOverride
# Editor/IDE directories
.vscode/
.idea/
*.suo
*.ntvs*
*.njsproj
*.sln
# Logs and temp files
*.log
*.tmp
*.swp
*.swo
*~
# PHP cache
/vendor/
# Build output
/dist/
/build/
# Python virtual environments
dev-browser/venv/
dev-browser/.venv/
.venv/
# Python compiled files
__pycache__/
*.pyc
*.pyo
*.pyd
# Tauri build output
**/src-tauri/target/
**/src-tauri/www/
**/src-tauri/gen/
EOF
echo ".gitignore created."
fi
# Initialize git if not already a repo
if [ ! -d .git ]; then
git init
echo "Git repository initialized."
fi
# Set or update remote
if git remote get-url origin &>/dev/null; then
git remote set-url origin "$REPO_URL"
echo "Remote 'origin' updated to $REPO_URL"
else
git remote add origin "$REPO_URL"
echo "Remote 'origin' added: $REPO_URL"
fi
echo "--- git remote -v:"
git remote -v
# Regenerate README.md before staging
if [ -f make_readme.py ]; then
echo "--- Updating README.md..."
python3 make_readme.py
fi
# Generate reports before staging
if [ -f dev-tools/zyx_planning_and_visuals/make_report.py ]; then
echo "--- Generating workspace reports..."
if ! python3 dev-tools/zyx_planning_and_visuals/make_report.py; then
echo "WARNING: report generation failed; continuing push flow." >&2
fi
fi
# Stage all files
echo "--- Running: git add ."
add_out="$(git add . 2>&1)"
add_rc=$?
if [ -n "$add_out" ]; then
echo "$add_out"
fi
if [ $add_rc -ne 0 ]; then
echo "ERROR: git add failed (exit $add_rc)" >&2
exit 1
fi
echo "--- git add complete"
# Show what is staged
echo "--- Staged files:"
git diff --cached --name-status 2>/dev/null || true
# Commit (skip if nothing to commit)
if git diff --cached --quiet; then
echo "--- Nothing new to commit. Working tree clean."
else
echo "--- Running: git commit"
git commit -m "Update Live CSS Editor"
if [ $? -ne 0 ]; then
echo "ERROR: git commit failed" >&2
exit 1
fi
fi
# Push using the current branch name
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo "--- Running: git push -v -u origin $BRANCH"
push_out="$(git push -v -u origin "$BRANCH" 2>&1)"
push_rc=$?
echo "$push_out"
if [ $push_rc -ne 0 ]; then
echo "ERROR: git push failed (exit $push_rc)" >&2
exit 1
fi
echo "--- Done: pushed to $REPO_URL ($BRANCH)."