feat: add comprehensive GitHub workflow and development tools

This commit is contained in:
Stiftung Development
2025-09-06 18:31:54 +02:00
commit ab23d7187e
10224 changed files with 2075210 additions and 0 deletions

70
scripts/dev-setup.sh Normal file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# Development setup script
set -e
echo "🚀 Setting up Stiftung development environment..."
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker first."
exit 1
fi
# Check if .env exists
if [ ! -f ".env" ]; then
echo "📝 Creating .env file from template..."
cp env-template.txt .env
echo "✅ Please edit .env file with your configuration"
fi
# Start services
echo "🐳 Starting Docker services..."
docker-compose up -d
# Wait for database to be ready
echo "⏳ Waiting for database to be ready..."
sleep 10
# Run migrations
echo "🔄 Running database migrations..."
docker-compose exec web python manage.py migrate
# Create superuser if needed
echo "👤 Creating superuser (if needed)..."
docker-compose exec web python manage.py shell << 'EOF'
from django.contrib.auth import get_user_model
User = get_user_model()
if not User.objects.filter(is_superuser=True).exists():
print("No superuser found. Please create one:")
exit()
else:
print("Superuser already exists")
EOF
# Collect static files
echo "📦 Collecting static files..."
docker-compose exec web python manage.py collectstatic --noinput
# Check health
echo "🏥 Checking application health..."
sleep 5
if curl -f -s http://localhost:8000/health/ > /dev/null; then
echo "✅ Application is healthy!"
else
echo "❌ Application health check failed"
fi
echo ""
echo "🎉 Development environment is ready!"
echo ""
echo "📊 Services:"
echo " - Application: http://localhost:8000"
echo " - Admin: http://localhost:8000/admin/"
echo " - HelpBox Admin: http://localhost:8000/help-box/admin/"
echo ""
echo "🛠️ Useful commands:"
echo " - View logs: docker-compose logs -f web"
echo " - Run tests: docker-compose exec web python manage.py test"
echo " - Django shell: docker-compose exec web python manage.py shell"
echo " - Create superuser: docker-compose exec web python manage.py createsuperuser"

232
scripts/git-workflow.sh Normal file
View File

@@ -0,0 +1,232 @@
#!/bin/bash
# Git workflow helper script
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Functions
print_header() {
echo -e "${BLUE}$1${NC}"
}
print_success() {
echo -e "${GREEN}$1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
print_error() {
echo -e "${RED}$1${NC}"
}
# Check if we're in a git repository
if [ ! -d ".git" ]; then
print_error "Not in a git repository"
exit 1
fi
# Main menu
echo "🔧 Git Workflow Helper"
echo "======================"
echo "1) Create feature branch"
echo "2) Commit changes"
echo "3) Push to GitHub"
echo "4) Create release"
echo "5) Clean up branches"
echo "6) Show status"
echo "0) Exit"
echo ""
read -p "Choose an option (0-6): " choice
case $choice in
1)
print_header "Creating feature branch"
read -p "Enter feature name (e.g., helpbox-improvements): " feature_name
if [ -z "$feature_name" ]; then
print_error "Feature name cannot be empty"
exit 1
fi
# Check if we're on main/develop
current_branch=$(git branch --show-current)
if [ "$current_branch" != "main" ] && [ "$current_branch" != "develop" ]; then
print_warning "You're not on main or develop branch. Current: $current_branch"
read -p "Continue anyway? (y/N): " continue_anyway
if [ "$continue_anyway" != "y" ] && [ "$continue_anyway" != "Y" ]; then
exit 0
fi
fi
branch_name="feature/$feature_name"
git checkout -b "$branch_name"
print_success "Created and switched to branch: $branch_name"
;;
2)
print_header "Committing changes"
# Check for changes
if git diff --quiet && git diff --cached --quiet; then
print_warning "No changes to commit"
exit 0
fi
# Show status
git status
echo ""
# Commit type
echo "Select commit type:"
echo "1) feat: New feature"
echo "2) fix: Bug fix"
echo "3) docs: Documentation"
echo "4) style: Code style changes"
echo "5) refactor: Code refactoring"
echo "6) test: Add or update tests"
echo "7) chore: Maintenance tasks"
read -p "Choose type (1-7): " commit_type_choice
case $commit_type_choice in
1) commit_type="feat" ;;
2) commit_type="fix" ;;
3) commit_type="docs" ;;
4) commit_type="style" ;;
5) commit_type="refactor" ;;
6) commit_type="test" ;;
7) commit_type="chore" ;;
*) print_error "Invalid choice"; exit 1 ;;
esac
read -p "Enter commit message: " commit_message
if [ -z "$commit_message" ]; then
print_error "Commit message cannot be empty"
exit 1
fi
git add .
git commit -m "$commit_type: $commit_message"
print_success "Changes committed: $commit_type: $commit_message"
;;
3)
print_header "Pushing to GitHub"
current_branch=$(git branch --show-current)
# Check if upstream exists
if ! git rev-parse --verify "origin/$current_branch" > /dev/null 2>&1; then
print_warning "Upstream branch doesn't exist. Setting up..."
git push -u origin "$current_branch"
else
git push
fi
print_success "Pushed to origin/$current_branch"
# Suggest creating PR
if [ "$current_branch" != "main" ] && [ "$current_branch" != "develop" ]; then
print_warning "Consider creating a Pull Request on GitHub"
echo "URL: https://github.com/yourusername/stiftung-starter/compare/$current_branch"
fi
;;
4)
print_header "Creating release"
# Check if on main branch
current_branch=$(git branch --show-current)
if [ "$current_branch" != "main" ]; then
print_error "Must be on main branch to create release"
exit 1
fi
# Get last tag
last_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
print_warning "Last tag: $last_tag"
read -p "Enter new version (e.g., v2.1.0): " new_version
if [ -z "$new_version" ]; then
print_error "Version cannot be empty"
exit 1
fi
# Create tag
git tag -a "$new_version" -m "Release $new_version"
git push origin "$new_version"
print_success "Created and pushed tag: $new_version"
;;
5)
print_header "Cleaning up branches"
# Show merged branches
echo "Merged branches that can be deleted:"
git branch --merged main | grep -v "main\|develop\|\*" | sed 's/^/ /'
echo ""
read -p "Delete merged branches? (y/N): " delete_merged
if [ "$delete_merged" = "y" ] || [ "$delete_merged" = "Y" ]; then
git branch --merged main | grep -v "main\|develop\|\*" | xargs -n 1 git branch -d
print_success "Deleted merged branches"
fi
# Clean remote tracking branches
git remote prune origin
print_success "Cleaned remote tracking branches"
;;
6)
print_header "Repository Status"
# Current branch
current_branch=$(git branch --show-current)
echo "📍 Current branch: $current_branch"
# Uncommitted changes
if ! git diff --quiet || ! git diff --cached --quiet; then
print_warning "You have uncommitted changes"
else
print_success "Working directory is clean"
fi
# Unpushed commits
if [ -n "$(git log origin/$current_branch..$current_branch 2>/dev/null)" ]; then
print_warning "You have unpushed commits"
else
print_success "All commits are pushed"
fi
# Show recent commits
echo ""
echo "📝 Recent commits:"
git log --oneline -5
# Show branches
echo ""
echo "🌿 Branches:"
git branch -v
;;
0)
print_success "Goodbye!"
exit 0
;;
*)
print_error "Invalid option"
exit 1
;;
esac