Git fetch on startup

August 28, 2019

A few days ago someone was doing something pretty interesting I thought I would share with everyone, and hopefully some people find it useful.

Normally if you want your server to automatically update from git you need to set up something like CI. This creative approach simply edits the
srcds_run file, adding this to the top:

cd "/home/container/garrysmod/addons"
    git remote add <link here>
    git fetch repository branch
    git checkout repository/branch
cd $OLDWD

Paired with scheduled tasks, this will allow you to automatically update, and restart your server at set times. If your server is restarted for some reason during the day, it would update before starting back up.

The advantage to this compared to CI is that it wont cause server instability if you have Lua Live Refresh enabled.