Skip to content

Instantly share code, notes, and snippets.

@RemiEven
Created July 6, 2016 10:36
Show Gist options
  • Save RemiEven/7e8cc88fc80d068e9ff181cbc7c8ec78 to your computer and use it in GitHub Desktop.
Save RemiEven/7e8cc88fc80d068e9ff181cbc7c8ec78 to your computer and use it in GitHub Desktop.
Fake continuous integration
#!/bin/bash
# Rémi Even, 06/07/2016
# This script provides a "fake" continuous integration. Rather than using (web)hooks, the target repo fetches the last commit id from origin. If it is different than the local one, it stops the service, updates the local files and restarts the service.
function stopService {
# Write the code to stop your service here
echo "Stopping service"
}
function startService {
# Write the code to start your service here
echo "Starting service"
}
git fetch origin master
localCommitHash=$(git rev-parse master)
originCommitHash=$(git rev-parse origin/master)
if [[ $localCommitHash != $originCommitHash ]]; then
stopService
git merge origin/master
startService
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment