4 ms·
One of my favorite GitOps tricks is adding a post-recieve.hook with the contents: #!/bin/bash echo -e "\e[1;31mUpdating worktree and fetching remo
by arjvik 2y ago
One of my favorite GitOps tricks is adding a post-recieve.hook with the contents:
#!/bin/bash
echo -e "\e[1;31mUpdating worktree and fetching remotes\e[m"
git --git-dir="$GIT_DIR" --work-tree="$GIT_DIR/.." reset --hard
git --git-dir="$GIT_DIR" fetch origin master
while read oldref newref refname; do
echo -e "\e[1;32mPushed ${refname##refs/heads/}\t${oldref::7} -> ${newref::7}\e[m"
done
echo -e "\e[1;31mRestarting service\e[m"
# Run whatever command is needed to restart the service
So that I can Heroku-style `git push` to my server (an ssh remote named "deploy") in order to deploy code!
- vs4vijay 2y agoInteresting hack! I'll be using it from now on. Do you have any tips for when a machine is behind a NAT? Specifically, I want a service to automatically pick up changes from Git whenever their origin is pushed, without using any fancy tools. I prefer a simple, "Taco Bell programming" approach.
- arjvik 2y agoI typically tunnel SSH through Cloudflare tunnels for this! Requires a bit of client-side config in the ~/.ssh/config file, but once you do that you can very easily SSH through a NAT!
- dewey 2y agoI recently set up Dokku for that kind of workflow recently, I'm super happy with my new setup which makes it very easy to throw up quick static pages or just push a Rails app and it'll basically just work Heroku style (It's using Heroku's buildpacks).