• Print

Author Topic: Remote file administration with github?  (Read 6011 times)

0 Members and 1 Guest are viewing this topic.

Offline sirrfuchs

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Remote file administration with github?
« on: September 26, 2016, 06:40:58 pm »
Hey, not sure if this is a valid topic for this forum, but I assume since it's development related, it should be okay...


I need some help getting my garry's mod server onto a Private Github Repo, and make it to where any pushes on the github will change the server files.

I've had someone set this up before, but they haven't been on steam in over 9 months.

Any help appreciated, I tried googling, but no luck!
« Last Edit: September 26, 2016, 07:02:41 pm by sirrfuchs »

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Remote file administration with github?
« Reply #1 on: September 27, 2016, 04:59:17 am »
You need to use Webhooks. They're similar to githooks, except they're for GitHub. You'll need a webserver to utilize them, so if you don't have one you'll either need to buy hosting or set up a webserver on your Garry's Mod server (assuming you're running a VPS/VDS). I don't have much time right now, but I'll try to update this post later today with more information.

Another approach is to use a Git repository on your server and then push any changes to the GitHub repo. This (IIRC) does not require a webserver and seems easier to me.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Remote file administration with github?
« Reply #2 on: September 30, 2016, 06:43:57 pm »
Another approach is to use a Git repository on your server and then push any changes to the GitHub repo. This (IIRC) does not require a webserver and seems easier to me.

I'm also curious as how to do this :O
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Remote file administration with github?
« Reply #3 on: September 30, 2016, 07:06:25 pm »
I'm also curious as how to do this :O
Quick search, maybe this'll do it for you?

Edit: Correction, this should do it.
bw81@ulysses-forums ~ % whoami
Homepage

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Remote file administration with github?
« Reply #4 on: October 03, 2016, 04:19:55 am »
I'm also curious as how to do this :O

Sorry for not replying earlier, I've been busy.

I followed this tutorial as a base for my automated pushing system. Looking back on this, I must have changed something because I swear I had it set up to automatically push to GitHub (as you can see from the mess that is my commit history).

Anyways, basically you have a bare repo (called Hub in the tutorial) and a normal repo (called Prime in the tutorial). In the repo folder (or in the .git folder within the repo folder, if it's not a bare repo) there is a folder named hooks. You'll want to edit the files accordingly:

(note, all of this is assuming you're running the server on Linux. I don't know to do these things in Windows)

post-update in Hub:

Code: Bash
  1. #!/bin/bash
  2.  
  3. echo
  4. echo "**** Pulling changes into UDodge Prime [UDodge Hub's post-update hook]" # this is optional, it just echos (prints to the command line) whenever it updates Prime
  5. echo
  6.  
  7. cd $HOME/gmodds/garrysmod/addons/udodge || exit # update the path to the location of your Prime repo
  8. unset GIT_DIR
  9. git pull hub master # make sure you have set up the 'hub' remote in Prime to point to the Hub repo, otherwise this won't work
  10.  
  11. exec git update-server-info

post-commit in Prime:

Code: Bash
  1. #!/bin/bash
  2.  
  3. echo
  4. echo "**** Pushing changes to UDodge Hub [UDodge Prime's post-commit hook]" # again, optional
  5. echo
  6.  
  7. git push hub # make sure you have that remote set

To extend this so it actually does what I said it would, you could set it up to push to GitHub whenever anything is changed. This would involve adding  to each of the files, probably right under the echos to make sure the changing directories doesn't mess up anything. Again, make sure you have a remote called 'origin' set to the GitHub repo.

Code: Bash
  1. git push origin

In the end I really didn't like this workflow because I would end up committing errors. When I could normally just rebase and gloss over those mistakes, with this workflow I can't do that without force pushing (which is dangerous). I'm not sure what a better workflow would be. I guess running a local server would be ideal because then you could test changes locally before pushing, but that comes with all the limitations of not having a dedicated server. Another possibility would be to push to the server, test the changes, and then push to GitHub. But at that point you may as well just use FTP to transfer the files and then create the commits on the server itself.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

  • Print