Automatically Deploy From GitHub To Server On Push

后端 未结 6 1652
陌清茗
陌清茗 2020-12-02 11:23

We have a VPS on linode, and code hosted on gitHub. How do we setup so when we push to gitHub, it also pushes automatically to our linode server. We are using PHP on the lin

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 11:58

    Maybe i'm out of context but i prefer to manually choose where to push from my command line eg: git push linode

    To do this i create a repository container in my linode server and created a post-receive hook that checkouts my folder to the last pushed commit

    Create a git repo container mkdir /var/repo && cd /var/repo git --bare init

    Create the post-receive hook in /var/repo/hooks/ touch post-receive nano post-receive chmod +x post-receive

    post-receive content #!/bin/sh git --work-tree=/var/www/ --git-dir=/var/repo checkout -f

    On your local repository git remote add linode root@:/var/repo git push linode

    your code is now deployed

提交回复
热议问题