Comment

Comment by arjvik

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!
parent arjvik 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton