1

Trying to deploy internal development from GitHub to a Centos 7 webserver, running into 2 issues.

Firstly, I'm using PHP and need to deploy the class files to a folder that is not /var/www/html/, where I have cloned the repository to using cd /var/www/ gh repo clone linkto/repo html (this may be the wrong thing to do).

Secondly, Prompting me to think that I've done the first part wrong, when trying to use gh repo sync linkto/repo i get the error can't determine source repository for GitUser/home because repository is not fork leading me to believe that instead of cloning I need to fork it. My intention here is that no code would ever be changed on the server-side just updated on GitHub then push to the server. Am I trying to do too much with GitHub? or am I trying to do it wrong?

EDIT: doing cd /var/www/html/ gh repo fork gh repo sync and setting a remote back to the origin has solved the second issue

Thanks,

Tom
  • 21
  • 1
  • 5
  • You might want to rethink Centos. Check Centos End of Life – Wakka Jan 18 '22 at 22:02
  • @Wakka Its only a temporary test deployment of the GitHub workflow, I just want to get the process working, will all translate over to 8/Stream – Tom Jan 18 '22 at 22:16
  • Cent OS 8 is gone. It hut EOL just before xmas. And Centos Stream is not suitable for a webserver delivering production. Just a heads up on that. It's not a replacement for Cetnos linux, It's a development & testing platform for RHEL. – Wakka Jan 18 '22 at 22:40
  • On your git issue, Number one. Am I right in saying you just want to store your classes outside of the web facing folders? – Wakka Jan 18 '22 at 22:42
  • @Wakka Yeah, off the top of my head in /usr/share/php/ I know I can do this manually, and potentially with a symbolic link that apache doesn't have permission for. – Tom Jan 18 '22 at 22:51
  • 1
    personally depending on the project and what they are I would either drop it in `/etc` or `/opt`. If its just scripts and what not I'd tend to go for the `/opt` directory and if it's a more robust system like say maybe a CMS or quite a technical api I'd go for the `/etc` directory. I'm not a great fan of having php files anywhere near apaches directories. I also don't feel that `/var` is the right directory for them either being a spool directory. – Wakka Jan 18 '22 at 23:01
  • @Wakka Ok, I'll look into where might be a better place for them for my use case. Do you have any pointers for being able to take the root folder in the repo `classes` and have it be synced to a different location when using `gh repo sync` so development can be done with the classes in the same repo as the rest of the site but have it split them out when deploying, alternatively can run a script to sync then cut/paste. – Tom Jan 18 '22 at 23:16
  • 1
    I do this using pipelines in bit bucket. If that's an option for you. but there is a way to do it with just git and a folder in linux and a scrpt. There is also Git hooks https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks. which is probably what you're after. There's hook policies specifically for server side – Wakka Jan 18 '22 at 23:20
  • @Wakka That looks like it. Thanks a bunch. – Tom Jan 18 '22 at 23:22
  • 1
    no worries mate have a good one – Wakka Jan 18 '22 at 23:23

1 Answers1

0

In cd /var/www/html/

Running once to setup:

gh repo fork with a remote set to the origin

Each time to update:

gh repo sync setting the base repository each time to update

Then using https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks a server-side post-receive hook to move the classes directory to the desired location

Tom
  • 21
  • 1
  • 5