Configure git after receiving

I am trying to follow the instructions http://jekyllrb.com/docs/deployment-methods/ to configure w2> for deploying Jekyll, however I find them a little tight for me. In this regard, there is a paragraph that says

In order for the remote server to handle the deployment for you every time you push the changes using Git, you can create a user account that has all the public keys that are allowed for deployment in the authorized_keys file. In this case, the installation of the hook after reception is performed as follows:

Question 1: Itโ€™s not clear to me where the โ€œuser accountโ€ (on Github? On the remote server) and (question 2) where this authorized_keys file will be created should be created. I have a known_hosts file in my home directory on my local machine with keys for github, etc. Is this an authorized_keys file?

The instructions tell you how to set up this post-reception, for example

 laptop$ ssh deployer@myserver.com server$ mkdir myrepo.git server$ cd myrepo.git server$ git --bare init server$ cp hooks/post-receive.sample hooks/post-receive server$ mkdir /var/www/myrepo 

The mkdir myrepo.git instruction is a bit unclear to me. For example, I put the Jekyll site in a git version control on my local machine and gave me this path /Users/me/Sites/nginxjekyll/_site/.git/

Question 3) Does this mean that after the mkdir myrepo.git instruction, I have to create the mkdir /Users/me/Sites/nginxjekyll/_site/.git/ on my remote server? Moving on, he says:

  cp hooks/post-receive.sample hooks/post-receive 

However, I don't have a hooks/post-receive.sample to copy? In the git repository on my local machine, I have post-update.sample, but not post-receive.sample. In addition, when I created the directory mkdir / Users / me / Sites / nginxjekyll / _site / .git / on my remote server, it did not create the post-update.sample file in it.

Can you clarify these instructions for me if you have a moment. Thanks in advance.

+7
git jekyll
source share
1 answer

Question 1: They relate to the user on the remote server.

Question 2: It depends on two scenarios: 1. You will need to add the public key of your local user in order to click on your remote server. 2. You will need to add the public key to the local user, which launches the hook after receiving, if ssh is required for deployment to another server. Most likely, only 1 is your problem, and 2 is not because the git repository and www server will be hosted on the remote server.

This means that you are adding the public key to the authorized_keys file in linux / unix environment. This file is usually located in the directory / home / $ USER / .ssh / authorized_keys. The authorized_keys file is in the same directory as the known_hosts file for the user.

Question 3: They explain how to set up a remote git repository. This does not have to be on the same path as your local repository.

OK - now to clarify what is really happening here. In the tutorial, you will learn how to set up a remote repository that will deploy a jekyll installation each time it is clicked.

This means that if you have a github rep, you cannot configure the server box. Most likely, you have set up a new remote on your remote server. Say you go to your server (usually with ssh), run pwd to find out your full path or set it in an environment variable:

 $DIR=`pwd` 

Now you can create a bare repo on this server:

 git init --bare $DIR/<SOMEDIRNAME>.git 

You now have a remote bare git repository on your server. Then you need to add a hook that allows it to expand the Jekyll site after receiving the click. The list you specified has a fairly simple deployment, but basically all it does is create a page-site-site-site-site, you can do it in several ways, I suggest you do it without violating your users as much as possible. this is a sample script that can do such a thing:

 #!/bin/bash # Assuming a directory structure for www: # $www_root/releases # $www_root/shared # $www_root/current # all releases go in releases dir as timestamps dirs # any logs or other shared items go in shared dir - shared/logs # current is a symlink to latest release unset GIT_DIR WWW_ROOT=/PATH/TO/WWW REPO_PATH=/PATH/TO/REPO REPO_BRANCH=master SITE_DIR=/PATH/TO/_SITE/DIR/IN/REPO DATE=$(date +"%Y%m%d%H%M") # get code if [ ! -d $WWW_ROOT/shared/git_maint ]; then mkdir -p $WWW_ROOT/shared/git_maint cd $WWW_ROOT/shared/git_maint git clone $REPO_PATH $WWW_ROOT/shared/git_maint git checkout master else cd $WWW_ROOT/shared/git_maint git pull git checkout master fi # do deploy if [ ! -d $WWW_ROOT/releases/$DATE ]; then mkdir $WWW_ROOT/releases/$DATE; fi cp -ar $WWW_ROOT/shared/git_maint/$SITE_DIR $WWW_ROOT/releases/$DATE ln -snf $WWW_ROOT/releases/$DATE $WWW_ROOT/current exit 0 

Something like this would be a good deployment. If you save this script on your remote server to a bare repository / file after receiving it, it will run every time the repository is clicked. Remember to make it executable: chmod 755 hooks/post-receive So, if you add this new remote to your git repository with:

 git remote add DEPLOY_PROD user@remote.server.com :/path/to/bare/repo 

Then git push DEPLOY_PROD - it will click on your remote, and then your remote repo will launch its hook after receiving, and then copy the bare repo down to the service directory, which can be deflated at almost any point. This directory is then used to convert the dir directory to the release directory, and then linked to the main directory.

Of course, all this is most likely redundant, and you can simply create a deployment script that runs from your local host to do all this via ssh.

The problem is that you cannot start cache servers directly from github for this methodology, so you need to get around it. I would advise you to check capistrano as a deployment strategy - the current / releases / shared dirs and git_maint dir are taken from their schema, it works well.

Let me know if you want any help here, I have a lot of experience in developing deployment strategies and automatic deployment, so depending on your situation, everything will depend.

+6
source share

All Articles