My current settings is that I have set my git bare repository in my VPS call it staging
.
So, when I do:
git push staging staging
I rerun my docker with mounted directory refer to the git-workdirs.
Now, I'd like to also add running the test inside that docker, and if something fails, roll it back to the previous (working) commit. [1]
what is the best way to do [1]
my current hooks looks like this:
$worktree = /my/work/directory
$gitdir = /my/repo/dir.git
$containername = mycontainer
git --work-tree=$worktree --git-dir=$gitdir checkout staging -f
cd $worktree
docker stop $containername || true
docker kill $containername || true
docker rm $containername || true
docker run -d -p $port1:$port2 --name $containername -v $worktree:/root/src -it $imagename bash -c $runscript