post-receive hook fails - any chance to see why?

前端 未结 6 1283
失恋的感觉
失恋的感觉 2021-01-15 05:07

I\'m implementing this approach to send updates to my website:

created bare repository to push to

$ mkdir website.git && cd website.git
$ git         


        
6条回答
  •  萌比男神i
    2021-01-15 05:44

    From comments above about reliability of targeting specific branches - I found this gist which targets the master branch from post-receive hook.

    #!/bin/bash 
    set -eu
    
    TARGET="/deployment-location-here"
    GIT_DIR="/trigger-location-here"
    BRANCH="master"
    
    while read oldrev newrev ref
    do
            # only checking out the master (or whatever branch you would like to deploy)
            if [[ $ref = refs/heads/"$BRANCH" ]];
            then
                    echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
                    git --work-tree="$TARGET" --git-dir="$GIT_DIR" checkout -f
            else
                    echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
            fi
    done
    

提交回复
热议问题