Files
basil/scripts/webhook-receiver.sh
Paul R Kartchner d1156833a2
Some checks failed
CI/CD Pipeline / Run Tests (pull_request) Has been cancelled
CI/CD Pipeline / Code Quality (pull_request) Has been cancelled
CI Pipeline / Lint Code (pull_request) Has been cancelled
CI Pipeline / Test API Package (pull_request) Has been cancelled
CI Pipeline / Test Web Package (pull_request) Has been cancelled
CI Pipeline / Test Shared Package (pull_request) Has been cancelled
Docker Build & Deploy / Build Docker Images (pull_request) Has been cancelled
E2E Tests / End-to-End Tests (pull_request) Has been cancelled
E2E Tests / E2E Tests (Mobile) (pull_request) Has been cancelled
Security Scanning / NPM Audit (pull_request) Has been cancelled
Security Scanning / Dependency License Check (pull_request) Has been cancelled
Security Scanning / Code Quality Scan (pull_request) Has been cancelled
Security Scanning / Docker Image Security (pull_request) Has been cancelled
CI/CD Pipeline / Build and Push Docker Images (pull_request) Has been cancelled
CI Pipeline / Build All Packages (pull_request) Has been cancelled
CI Pipeline / Generate Coverage Report (pull_request) Has been cancelled
Docker Build & Deploy / Push Docker Images (pull_request) Has been cancelled
Docker Build & Deploy / Deploy to Staging (pull_request) Has been cancelled
Docker Build & Deploy / Deploy to Production (pull_request) Has been cancelled
Security Scanning / Security Summary (pull_request) Has been cancelled
feat: add CI/CD pipeline, backup system, and deployment automation
## Summary
- Add complete CI/CD pipeline with Gitea Actions for automated testing, building, and deployment
- Implement backup and restore system with full database and file backup to ZIP
- Add deployment automation with webhook receiver and systemd service
- Enhance recipe editing UI with improved ingredient parsing and cooking mode features
- Add comprehensive documentation for CI/CD, deployment, and backup features

## CI/CD Pipeline
- New workflow in .gitea/workflows/ci-cd.yml with test, build, and deploy stages
- Automated Docker image building and pushing to registry
- Webhook-triggered deployments to production servers

## Backup & Restore
- New backup service with ZIP creation including database dump and uploads
- REST API endpoints for create, list, download, restore, and delete operations
- Configurable backup path via BACKUP_PATH environment variable

## Deployment
- Automated deployment scripts (deploy.sh, manual-deploy.sh)
- Webhook receiver with systemd service for deployment triggers
- Environment configuration template (.env.deploy.example)

## Documentation
- docs/CI-CD-SETUP.md - Complete CI/CD pipeline setup guide
- docs/DEPLOYMENT-QUICK-START.md - Quick deployment reference
- docs/BACKUP.md - Backup and restore documentation
- docs/REMOTE_DATABASE.md - Remote database configuration guide
- scripts/README.md - Deployment scripts documentation

## Web Improvements
- Enhanced ingredient parser with better unit and quantity detection
- Improved recipe editing interface with unified edit experience
- Better cooking mode functionality
- Updated dependencies in package.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 05:04:39 +00:00

107 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Webhook Receiver for Basil Deployments
# This script sets up a simple webhook endpoint that triggers deployments
set -e
# Configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PORT="${WEBHOOK_PORT:-9000}"
SECRET="${WEBHOOK_SECRET:-changeme}"
LOG_FILE="$SCRIPT_DIR/../webhook.log"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log() {
echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
}
warning() {
echo -e "${YELLOW}[$(date +'%Y-%m-%d %H:%M:%S')] WARNING:${NC} $1" | tee -a "$LOG_FILE"
}
# Install webhook if not present
install_webhook() {
if ! command -v webhook &> /dev/null; then
log "Installing webhook..."
if command -v apt-get &> /dev/null; then
sudo apt-get update && sudo apt-get install -y webhook
elif command -v yum &> /dev/null; then
sudo yum install -y webhook
else
warning "Please install 'webhook' manually: https://github.com/adnanh/webhook"
exit 1
fi
fi
}
# Create webhook configuration
create_webhook_config() {
cat > "$SCRIPT_DIR/webhook-config.json" <<EOF
[
{
"id": "basil-deploy",
"execute-command": "$SCRIPT_DIR/deploy.sh",
"command-working-directory": "$SCRIPT_DIR/..",
"response-message": "Deployment triggered successfully",
"trigger-rule": {
"and": [
{
"match": {
"type": "value",
"value": "$SECRET",
"parameter": {
"source": "header",
"name": "X-Webhook-Secret"
}
}
}
]
},
"pass-environment-to-command": [
{
"envname": "DOCKER_USERNAME",
"source": "string",
"name": "DOCKER_USERNAME"
},
{
"envname": "DOCKER_REGISTRY",
"source": "string",
"name": "DOCKER_REGISTRY"
},
{
"envname": "IMAGE_TAG",
"source": "string",
"name": "IMAGE_TAG"
}
],
"trigger-rule-mismatch-http-response-code": 403
}
]
EOF
log "Webhook configuration created at $SCRIPT_DIR/webhook-config.json"
}
# Start webhook server
start_webhook() {
log "Starting webhook server on port $PORT..."
log "Webhook URL: http://localhost:$PORT/hooks/basil-deploy"
log "Secret: $SECRET"
log "Press Ctrl+C to stop"
webhook -hooks "$SCRIPT_DIR/webhook-config.json" -port "$PORT" -verbose
}
# Main
main() {
install_webhook
create_webhook_config
start_webhook
}
main "$@"