How georgknabl/git-ssh-deploy works
Main Components
• Local Git Environment: Include the Git repository where files are tracked, the configuration stored in .git/config (containing environment settings like host, user, remote directory, commands, etc.), and the local execution of the deployment script.
• Deployment Script (git-ssh-deploy.sh): This is the core component that coordinates operations. Represent it as the controller that reads configuration, detects changes via “git diff”, fires off commands, and bundles files into a tarball.
• SSH Channel: A communication component that represents the secure SSH connection. Show the use of tools like scp (to copy the tarball) and SSH command execution (to extract files and run pre/post commands on the remote server).
• Remote Server: Illustrate this component as the destination system, including:
o The file extraction process (receiving the tarball and unpacking it into the specified remote directory).
o The state management on the server (logging the commit ID in .git-ssh-deploy-state-commit-id.log).
o Execution of pre-deployment and post-deployment commands.
o Optionally, a health check (HTTP request triggered after deployment).
Relationships and Interactions
• Start at the local Git repository, where changes are detected using Git diff.
• The Deployment Script takes these changes, bundles them (tarball), and then uses scp to copy to the remote server.
• On the remote side, the server extracts the tarball and executes any configured commands; state is then logged for future reference.
Architectural Patterns and Design Principles
• Configuration Driven — Emphasize that the behavior of the deployment (like command executions and exclusions) is governed by settings in .git/config.
• Lightweight, synchronous execution — As a Bash script, the tool is not built with asynchronous pipelines or separate services, so there isn’t a “service-oriented” component, but rather a linear, well-delineated workflow.
Technologies and Key Tools Highlighted
• Git and Git Config: Used for version control, diff calculation, and environment-specific configuration.
• SSH and SCP: For secure connection and file transfer.
• Bash scripting and tar: For file bundling, remote command execution, and offline state logging.