Add GitHub Actions deployment workflow

- Add deployment workflow with test, build, and deploy jobs
- Add testing workflow for PRs
- Add deployment scripts (deploy, healthcheck, rollback)
- Add systemd service configuration
- Update Makefile with CI/CD targets
- Add comprehensive deployment documentation
This commit is contained in:
root
2025-10-30 12:19:57 +00:00
parent ee354d1d35
commit 5e38292d2e
9 changed files with 1849 additions and 10 deletions
+47 -10
View File
@@ -1,4 +1,4 @@
.PHONY: run build test clean dev prod docker-build docker-run
.PHONY: run build test clean dev prod docker-build docker-run ci-test ci-build health-check install-service update-service
# Development
dev:
@@ -57,15 +57,52 @@ docker-run:
@echo "🐳 Running Docker container..."
docker run -p 1999:1999 cv-server:latest
# CI/CD Targets
ci-test:
@echo "🧪 Running CI tests..."
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
@echo "✓ CI tests complete"
ci-build:
@echo "🔨 Building for CI/CD..."
mkdir -p build
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o build/cv-server .
@echo "✓ CI build complete: build/cv-server"
health-check:
@echo "🏥 Running health check..."
@./scripts/healthcheck.sh
install-service:
@echo "📦 Installing systemd service..."
sudo cp config/systemd/cv.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable cv
@echo "✓ Service installed and enabled"
update-service:
@echo "🔄 Updating systemd service..."
sudo cp config/systemd/cv.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl restart cv
@echo "✓ Service updated and restarted"
# Help
help:
@echo "Available commands:"
@echo " make dev - Run in development mode (hot-reload enabled)"
@echo " make prod - Run in production mode"
@echo " make build - Build production binary"
@echo " make run - Build and run binary"
@echo " make test - Test all endpoints"
@echo " make test-errors - Test error handling"
@echo " make clean - Remove build artifacts"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Docker container"
@echo " make dev - Run in development mode (hot-reload enabled)"
@echo " make prod - Run in production mode"
@echo " make build - Build production binary"
@echo " make run - Build and run binary"
@echo " make test - Test all endpoints"
@echo " make test-errors - Test error handling"
@echo " make clean - Remove build artifacts"
@echo " make docker-build - Build Docker image"
@echo " make docker-run - Run Docker container"
@echo ""
@echo "CI/CD commands:"
@echo " make ci-test - Run tests for CI pipeline"
@echo " make ci-build - Build binary for CI/CD"
@echo " make health-check - Check service health"
@echo " make install-service - Install systemd service"
@echo " make update-service - Update and restart service"