So I develop Discord.JS bots, and host them on a server I own in my home. I generally program and test them on my personal device, but host them on a dedicated device. The problem is, in order for me to make an update, I have to manually FTP into this device to edit the files.
I use GitHub and Git for these projects, and I have a development branch and a production branch. I'm wondering if it's possible to automate the process; when I push into the production branch, it will update the files on the server for me.
Keep in mind I am still semi-new to GitHub so if it is simple I do apologize for that. Is there any software for this, or can it be done through Git? Thanks! :)
As @eftshift0 mentioned in their comment, you can use a cronjob and git clone.
To do this, you will need to edit the crontab file, use the crontab -e
command.
At the bottom of the file, insert:
frequency git clone https://<github_username>:<url_encoded_github_password>@github.com/<github_username>/<repo_name> /path/to/directory
frequency
should be something like * * * * *
. You can find what you need here. It will be the interval between which updates are made.
To url encode your password, you can use this
Edit:
As @eftshift0 has mentioned, you can also create a bash file, and then run that from crontab.
The file would contain:
#!/bin/bash
cd /path/to/
git clone https://<github_username>:<url_encoded_github_password>@github.com/<github_username>/<repo_name>
Your repo would be in /path/to/<repo_name>
In crontab -e
you would have to append:
frequency /bin/sh /path/to/file.sh