TheStudentProgrammer
TheStudentProgrammer

Reputation: 53

A way to automate git pull on Raspberry Pi

I am hosting a discord bot on a Raspberry Pi. This is my first personal project and wanted to know if there was a way to automate git pull without having to remote in my device. That way I can continue to make the discord bot better without having to worry about updating it. Is there a tool that would be helpful for this task?

Thank you for your time.

Upvotes: 0

Views: 1397

Answers (2)

Tin Nguyen
Tin Nguyen

Reputation: 5330

There are solutions that automatically update. Doing it through git pull and restarting the bot works but it isn't a clean solution. I would recommend to dockerize your Discord bot project and run https://github.com/containrrr/watchtower

Watchtower is responsible to update your docker container once a new docker image is released.
In GitHub, Gitlab etc. it is possible to define CI/CD that automatically updates the docker image once you git push new code to it. You can also run some checkers beforehand to make sure you are only deploying code that works.

Upvotes: 1

Vincent Schmandt
Vincent Schmandt

Reputation: 502

You can look into cron jobs to run a task periodically (e.g. git pull). This could look something like this:

*/15 * * * * git -C /home/me/gitprojectdir pull

(taken from Git auto-pull using cronjob)

Upvotes: 4

Related Questions