Files
basil/scripts/webhook-receiver.sh
Paul R Kartchner f5f8bc631c
Some checks failed
CI Pipeline / Test Web Package (push) Waiting to run
CI Pipeline / Test Shared Package (push) Waiting to run
CI/CD Pipeline / Run Tests (push) Failing after 1s
CI/CD Pipeline / Code Quality (push) Failing after 5m39s
Basil CI/CD Pipeline / Code Linting (push) Has been cancelled
Basil CI/CD Pipeline / API Tests (push) Has been cancelled
Basil CI/CD Pipeline / Web Tests (push) Has been cancelled
Basil CI/CD Pipeline / Security Scanning (push) Has been cancelled
Basil CI/CD Pipeline / Build All Packages (push) Has been cancelled
Basil CI/CD Pipeline / E2E Tests (push) Has been cancelled
Basil CI/CD Pipeline / Build & Push Docker Images (push) Has been cancelled
Basil CI/CD Pipeline / Trigger Deployment (push) Has been cancelled
Basil CI/CD Pipeline / Shared Package Tests (push) Has been cancelled
CI Pipeline / Lint Code (push) Failing after 5m37s
CI Pipeline / Test API Package (push) Failing after 1s
E2E Tests / End-to-End Tests (push) Failing after 2s
E2E Tests / E2E Tests (Mobile) (push) Failing after 1s
CI/CD Pipeline / Build and Push Docker Images (push) Has been skipped
Security Scanning / Docker Image Security (push) Failing after 21s
CI Pipeline / Build All Packages (push) Has been cancelled
CI Pipeline / Generate Coverage Report (push) Has been cancelled
Docker Build & Deploy / Push Docker Images (push) Has been cancelled
Docker Build & Deploy / Deploy to Staging (push) Has been cancelled
Docker Build & Deploy / Deploy to Production (push) Has been cancelled
Docker Build & Deploy / Build Docker Images (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
Security Scanning / Dependency License Check (push) Has been cancelled
Security Scanning / NPM Audit (push) Has been cancelled
Security Scanning / Code Quality Scan (push) Has been cancelled
feat: consolidate CI/CD pipeline with Harbor integration
- Merged 5 workflows into single main.yml
- Added Harbor registry support for local container storage
- Updated deployment script with Harbor login
- Enhanced webhook receiver with Harbor password env var
- Updated docker-compose.yml to use Harbor images
- Archived old workflow files for reference
- Added comprehensive workflow documentation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-14 06:48:00 +00:00

112 lines
2.6 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": "HARBOR_PASSWORD",
"source": "string",
"name": "HARBOR_PASSWORD"
},
{
"envname": "IMAGE_TAG",
"source": "payload",
"name": "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 "$@"