A minimalist git deployment tool with bash script and cron on linux. It works for machine behind firewall and it has minimal dependancies. It will ensure the repo is update-to-date with master branch and it can call a script before and after an update.
Note: tested on Ubuntu 16.04.4 x64
This can be convenient for staging environment. (flock prevent concurrent tasks.)
- (if not already done) Update:
sudo apt-get update - (if not already done) Generate a new ssh key for this machine:
ssh-keygen -t rsa - (optional) Make sure timezone is configured. ex:
sudo timedatectl set-timezone America/New_York - Add Deploy keys on your GitHub repo:
- From repo: Settings tab
- Press on: Deploy keys
- Press on: Add deploy key
- Paste the content of id_rsa.pub (
cat .ssh/id_rsa.pub)
- Clone the repo:
git clone https://github.com/doxakis/check-new-code - Add scheduled task:
crontab -e- ex: Check every minute.
* * * * * flock /root/myrepo-check-new-code.lock -c "bash /root/check-new-code/check-new-code.sh /root/myrepo /root/myrepo/beforeUpdate.sh /root/myrepo/afterUpdate.sh /root/myrepo-updatelog.txt"
- ex: Check every minute.
- git directory on server
- before update script (if script missing, skip it)
- after update script (if script missing, skip it)
- log file