A lightweight, universal CD/GitOps service for deploying anything to anywhere. CD-Gun is a systemd-based agent that monitors git repositories and executes actions when changes are detected.
Status: π v0.1.1 (Early Development)
This project was developed with the assistance of GitHub Copilot. While the concept, architecture, design decisions, and comprehensive testing were provided by the project author, the implementation code was generated and refined using AI assistance. This approach demonstrates modern collaborative development practices combining human creativity with AI-powered code generation.
- π Universal: Works with any git-compatible repository (GitHub, GitLab, Gitea, self-hosted, etc.)
- π§ Flexible: Define custom actions in shell scripts
- πͺΆ Lightweight: ~6MB binary, minimal resource usage
- π Independent: No dependencies on Kubernetes, Docker, or specific platforms
- π Simple: Easy to configure with YAML
- π‘οΈ Secure: Runs as unprivileged systemd service
git clone https://github.com/omnorm/cd-gun.git
cd cd-gun
make build
sudo make install
# Start the service
systemctl start cd-gun- Create a config file
/etc/cd-gun/config.yaml:
agent:
name: "cd-gun-agent"
log_level: "info"
log_file: "/var/log/cd-gun.log" # Optional: omit to log to stdout/journalctl
state_dir: "/var/lib/cd-gun"
cache_dir: "/var/cache/cd-gun/repos"
poll_interval: "5m"
repositories:
- name: "my-app"
url: "https://github.com/myorg/app.git"
branch: "main"
watch_paths:
- "src/"
- "package.json"
poll_interval: "5m"
action:
type: "shell"
script: "/opt/cd-gun/scripts/deploy.sh"
timeout: "10m"- Create a deployment script
/opt/cd-gun/scripts/deploy.sh:
#!/bin/bash
set -e
echo "Deploying $CDGUN_REPO_NAME from $CDGUN_OLD_HASH to $CDGUN_NEW_HASH"
cd "$CDGUN_REPO_PATH"
npm ci
npm run build
rsync -av dist/ /var/www/app/
systemctl reload nginx
echo "Deployment successful!"- Check status:
systemctl status cd-gun
journalctl -u cd-gun -fWhen executing your deployment scripts, CD-Gun provides these variables:
| Variable | Description |
|---|---|
CDGUN_REPO_NAME |
Repository name from config |
CDGUN_REPO_URL |
Repository URL |
CDGUN_REPO_PATH |
Local cache path |
CDGUN_BRANCH |
Branch being monitored |
CDGUN_CHANGED_FILES |
Changed files (comma-separated) |
CDGUN_OLD_HASH |
Previous commit hash |
CDGUN_NEW_HASH |
Current commit hash |
Full reference: docs/ENVIRONMENT_VARIABLES.md
# Reload configuration
kill -HUP $(pgrep cd-gun-agent)
# Force check all repositories
kill -USR1 $(pgrep cd-gun-agent)
# Graceful shutdown
systemctl stop cd-gun# Build
make build
# Run locally for testing
./bin/cd-gun-agent -config examples/simple-deploy.yaml -log-level debug
# Run tests
make test
# Clean
make cleancmd/cd-gun-agent/ # Application entry point
internal/
βββ app/ # Main application & event loop
βββ config/ # Configuration management
βββ executor/ # Action execution
βββ monitor/ # Repository monitoring
βββ state/ # State management
βββ logger/ # Logging
examples/ # Example configurations
deployments/ # systemd service file
docs/ # Documentation
- ARCH.md β Architecture and design
- PLAN.md β Implementation status
- STATUS.md β Current development status
- CONTRIBUTING.md β How to contribute
- SECURITY.md β Security policy and best practices
- RELEASE.md β Release process
- CODE_OF_CONDUCT.md β Community guidelines
- docs/ENVIRONMENT_VARIABLES.md β Environment variables guide
- docs/CONFIGURATION_SPLIT.md β Splitting config into multiple files
- docs/SUDO_SETUP.md β Sudo configuration for privileged operations
- examples/ β Configuration and script examples
- Web application deployment β Auto-deploy on git push
- Configuration management β Auto-update service configs
- Multi-repo coordination β Monitor and sync multiple repositories
- Custom deployment pipelines β Run any shell script on changes
If you're wondering how CD-Gun compares to other tools:
| Tool | Best For | vs CD-Gun |
|---|---|---|
| Argo CD / Flux | Kubernetes clusters | CD-Gun is simpler, works on plain servers without K8s |
| Jenkins / GitHub Actions | Full CI/CD pipelines | CD-Gun is lighter, uses pull model instead of webhooks |
| Ansible pull | Config management | Similar pull-based approach, but CD-Gun is script-agnostic |
| Webhook services | Git β script execution | CD-Gun polls instead of requiring open webhooks; works with private networks |
CD-Gun is best for: Single/multiple servers, simple deployments, no K8s, minimal dependencies, custom bash-based workflows.
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License β see the LICENSE file for details.
Copyright (c) 2025 Permishen Denaev