The Auto-Committer is a Dockerized Python application designed to automatically commit and push changes to a Git repository at regular intervals. This tool helps keep repositories up to date without manual intervention ensuring that your codebase remains current with minimal effort. This version has been extended to offer a few additional features from the forked version.
- Features
- Install
- Environment Variables
- Pattern Usage Examples
- Pattern Syntax
- Don't ignore .gitignore
- Important Notes
- Troubleshooting
- License
- Automatic Commits: Regularly commits and pushes changes to a specified Git repository
LAB_REPO_NAME. - Configurable Intervals: Allows you to set the interval at which commits are made
COMMIT_INTERVAL_SECONDS. - Logging: Keeps track of commit activities and errors in a log file
LAB_LOG_FILE_PATH. - Dockerized: Easily deployable with Docker and Docker Compose.
NEW: Use AUTO_COMMIT_PATTERNS to specify which files to track, or leave it unset to commit everything!
REMOVED: COMMIT_SPECIFIC_DIRECTORY as option clashed with AUTO_COMMIT_PATTERNS pattern matching and deemed redundant.
Installation via Docker Compose
- Setup Git repository :
cd /path/to/your/repo
git init
git remote add origin https://github.com/yourusername/yourrepo.git- Create docker project directory:
mkdir auto-committer && cd auto-committer- Create
compose.yaml:
services:
auto-committer:
container_name: auto-committer
image: ghcr.io/iamdabe/auto-committer:latest
restart: unless-stopped
ports:
- "5009:5009"
env_file:
- .env
volumes:
- /path/to/your/repo:/repo- Create
.envfile:
# Required
AUTO_COMMIT_REPO_PATH=/repo
GITHUB_TOKEN=github_pat_token
LAB_REPO_OWNER=github_repo_owners_username
LAB_REPO_NAME=github_reponame
USEREMAIL=you@example.com
USERNAME=github_username
# Optional
COMMITTER=MYSERVER
COMMIT_INTERVAL_SECONDS=300
AUTO_COMMIT_PATTERNS=- Deploy:
docker compose up -dIf you prefer to build locally:
services:
auto-committer:
build: .
container_name: auto-committer
restart: unless-stopped
ports:
- "5009:5009"
env_file:
- .env
volumes:
- /path/to/your/repo:/repoThen run:
docker compose up -d --buildThe AUTO_COMMIT_REPO_PATH environment variable should point to the mount point inside the container, not the host path.
Default: /repo (recommended)
volumes:
- /host/path/to/your/repo:/repo # Maps host path to /repo in container
# Then in .env:
AUTO_COMMIT_REPO_PATH=/repo # Uses the container pathAUTO_COMMIT_REPO_PATH=/repo # Path to git repository inside container
GITHUB_TOKEN=ghp_pap_your_token # Github personal access token
LAB_REPO_OWNER=your_git_username # Github repository owner
LAB_REPO_NAME=your_git_reponame # Github repository name
USEREMAIL=you@example.com # Github committer email
USERNAME=Your Name # Github committer name# Committer identifier for commit messages (default: 'AUTO')
COMMITTER=MYSERVER
# Interval between checks in seconds (default: 300 = 5 minutes)
COMMIT_INTERVAL_SECONDS=300
# Log file path (default: /tmp/auto_committer.log)
LAB_LOG_FILE_PATH=/var/log/auto_committer.log
# File patterns to monitor (comma-separated glob patterns)
# If NOT SET or COMMENTED OUT: Commits ALL changes (default behavior)
# If SET: Only commits files matching these patterns
# Examples:
# Only Docker Compose files:
# AUTO_COMMIT_PATTERNS=*/compose.yaml,*/.env
AUTO_COMMIT_PATTERNS=In your .env:
AUTO_COMMIT_PATTERNS= ← Leave unset or comment outResult: Commits all changes in the repository (like git add --all)
AUTO_COMMIT_PATTERNS=*/compose.yaml,*/.envResult: Only tracks compose.yaml and .env files in any subdirectory
AUTO_COMMIT_PATTERNS=*.py,*.js,*.mdResult: Only tracks Python, JavaScript, and Markdown files
AUTO_COMMIT_PATTERNS=*/Dockerfile,*/compose.yaml,*/.env,*.mdResult: Tracks Dockerfiles, compose files, .env files, and markdown files
AUTO_COMMIT_PATTERNS=configs/*,scripts/*.shResult: Only tracks files in configs/ dir and .sh files in scripts/ dir
Uses Python's glob patterns:
*- matches any characters in a single directory level**- matches any characters across multiple directory levels?- matches a single character[abc]- matches any character in brackets
# Single level wildcard
*.txt # All .txt files in root
*/config.yaml # config.yaml in any immediate subdirectory
# Recursive wildcard
**/*.py # All .py files in any subdirectory (any depth)
# Multiple patterns (comma-separated)
*.md,*.txt # All markdown and text files
# Specific paths
docker/*/compose.yaml # compose.yaml files in docker subdirectories- Scans repository for files matching your patterns
- Only adds matching files with
git add <file> git commitand pushes only those files
- Runs
git add --all git commitand pushes all changes
This script does not override your .gitignore file - Git's ignore rules are still respected. It's best practice to maintain a .gitignore file in your repository to prevent sensitive files, logs and unwanted data from being accidentally committed even when using pattern filtering.
- Patterns are case-sensitive
- The
.gitdirectory is always excluded - If patterns don't match any files, nothing will be committed
- Patterns use forward slashes
/even on Windows - Multiple patterns are OR'd together (any match qualifies)
- Ensure Docker and Docker Compose are installed and running.
- Verify that the .env file is correctly configured.
- Check the log file specified by LAB_LOG_FILE_PATH for any errors.
This project is licensed under the Apache License. See the LICENSE file for details.
Forked from hanisntsolo/auto-committer.