Hey Y’all. I’ve been registered on FreeCodeCamp forever but not really active till like two weeks ago. I just got to the responsive web design section of the FCC curriculum and because of the way my brain works, it couldn’t pass up this opportunity to get completely distracted by getting my experiments on my phone.
I don’t know if this is the right subform, but my end goal way down the line is a career in DevOps… and I guess this is CI/CD inspired?
I have a Raspberry Pi set up as a little git/nginx server on Ubuntu 20.04.1 I just found out about git post-receive hooks. What I’m looking to do is after receiving a pushed commit, have a script pull the repo into a temp folder and copy the relevant files to the folder nginx is serving the static web content out of.
First: Sanity Check? Like, I know this workflow doesn’t scale, but is this reasonable as a quick way to get my little css experiments on my phone? Is there something I’m super not thinking about that I should be? Please point me in the vague direction of “Best Practice,” considering how jerry-rigged this feels, haha.
Specifically. I can’t get the post-receive script to actually execute:
cd /data/www/tmp/WebDev/ && echo "3. Working Directory changed to `pwd`" >> $LOGPATH git pull origin master && echo "4. Repo Pulled" >> $LOGPATH
The big clue I don’t know how to decipher: When I push a commit, I get something like this:
remote: fatal: not a git repository: '.'
Obviously the push itself goes through as the git pull origin master works fine from the cli when I do it myself, and the rest works and populates my little log file. I can do a regular pull to the repos on my other computers and I know there’s a .git file in that directory.
Any Ideas? Is it weird that I’m calling git pull from within the post-receive hook?
Feel free to tell me to go live in a cave for a while and read a few books on git, but it’d be really cool to get this working.
EDIT: I should clarify, I can cd to the same place I have the script go before logging its pwd, and have no issue running the pull from there manually