A tool to sync specific files from a Git repository to local filesystem.
- Fetch specific files from a Git repository using commit hash
- Support for SSH authentication with deploy keys
- YAML configuration file
- Git client installed
- SSH client installed
- Read access to target Git repository
$ go install github.com/your-org/git-file-sync@latestCreate a config.yaml file:
git:
repoUrl: "git@github.com:your-org/your-repo.git"
commitHash: "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
files:
# Single file
- source: "configs/production/app-config.json"
destination: "/app/configs/app-config.json"
# Another single file
- source: "assets/logo.svg"
destination: "/app/static/logo.svg"
# Entire directory
- source: "scripts/"
destination: "/app/scripts/"
sshPrivateKeyPath: "/secrets/deploy_key"# Use default config.yaml in current directory
git-file-sync
# Specify custom config file
git-file-sync -config=/path/to/config.yaml
# Enable verbose logging
git-file-sync -verboseUse as an init container to provide configuration files to your main application:
- Deploy configuration files before application startup
- Update configuration without rebuilding application images
- Share files between containers via volumes
Fetch specific files during build or deployment:
- Pull build scripts from a central repository
- Retrieve environment-specific configurations
- Sync deployment manifests
Manage application configurations across environments:
- Use commit hashes for versioned configuration deployment
- Rollback to previous configurations by changing commit hash
- Audit configuration changes through Git history
Distribute static files to multiple locations:
- Sync documentation files
- Deploy static website assets
- Distribute shared libraries or scripts
- Create a test repository with sample files
- Generate an SSH deploy key:
$ ssh-keygen -t ed25519 -f deploy_key -N "" - Add the public key to your repository as a read-only deploy key
- Create a test config file:
git: repoUrl: "git@github.com:your-org/test-repo.git" commitHash: "your-commit-hash" files: - source: "test.txt" destination: "/tmp/test.txt" sshPrivateKeyPath: "./deploy_key"
- Run the syncer:
$ git-file-sync -config=test-config.yaml -verbose
This project is licensed under the MIT License.