How to deploy jekyll on slicehost - github

I have jekyll blog up and running locally. I am not sure how to push the content to slicehost. They have an instruction page but I am not able to follow the instruction.
I have all my content on github. Just need to know how to make post-update hook work?

To deploy a generated Jekyll site, you just need to copy the contents of the local _site directory to the appropriate remote directory on your server (often public_html, but it depends on the server configuration).
Personally, I think the easiest way is to just use rsync, assuming you can use rsync with your server. Then it's as simple as executing the command
$ rsync -avz --delete _site/ user#host:/path/to/web/root
to deploy your site. For my Jekyll-based sites, I encapsulate this in a Rake task so I can just do
$ rake site:deploy
to copy the site to the server.
If you can't use rsync, you can always transfer the _site directory via FTP, which is also pretty easy to do (and with a bit of Ruby scripting, can be automated using Rake as well).
You can use Git, as noted in the Jekyll docs. You will have to have Git installed on your server, and access to using it. If that's the case, you have to create a bare Git repo on your server. In the bare repo, you then create a post-update hook to check out the latest copy of the site. You do this by creating a script at $BARE_REPO/hooks/post-update with contents like the following (as noted here):
#!/bin/sh
unset GIT_DIR && cd /path/to/web/root && git pull
You then clone the bare repository to your web root, like so:
$ cd /path/to/web/root
$ cd ..
$ rm -rf root
$ git clone /path/to/bare/repo.git root
As you can see, it's often easier to use rsync or FTP instead of Git.

Related

Basic Github Repo Creation

I just created my first Github Repo through the Github Bash on Windows 10.
I ran:
$ mkdir Projects
$ mkdir Projects/DataScientistsToolbox
$ mkdir Projects/DataScientistsToolbox/sample
$ cd Projects/DataScientistsToolbox/sample
$ git init
Initialised empty Git repository in /home/osboxes/Projects/DataScientistsToolbox/sample/.git/
$ ls -la
I am really struggling with understanding this code. So I created three directories: projects, datascientiststoolbox, and sample.
What does the cd command on my code do?
Does the git init code run the creation?
What does the ls -la do?
Lastly, I can't seem to find where the repo is saved on my computer, is it located on the desktop or in a special spot?
Thank you, sorry about the large amount of questions.
The cd command lets you change your working directory.
Yes, git init creates (initalizes) a new repository on your machine in your current working directory.
ls displays all files and directories in the current working directory. -la changes the way they are printed.
pwd makes your machine print the working directory. Use it to find out where your repository was created.
Read here about how to create a GitHub Repository. And this is a list of basic unix commands - it may help you to get started with unix systems.
You created only one repository with git init. cd stands for change directory, it's like when you double-click a folder to open it.
So basically your repo is in Projects/DataScientistsToolbox/sample.
ls is used for listing all files in the current directory you're in. -la are flags for different styles of displaying (try running just ls).
Also, all these commands have nothing to do with GitHub. They're a part of git.

How to use git lfs with Visual Studio Team Services hosted build agents

I use git lfs to store the large files of my git repo. I then try to build this repo with hosted agents. My build is pretty simple. It has a single task: Execute PowerShell. In the invoked script, the first thing that I want to do is to fetch my lfs dependencies. I therefore have the following in my script:
& git lfs fetch
Unfortunately, my build fails with the following error:
2016-03-04T19:49:05.7021988Z ##[error]git: 'lfs' is not a git command. See 'git --help'.
2016-03-04T19:49:05.7031986Z ##[error]Did you mean this?
2016-03-04T19:49:05.7041987Z ##[error] flow
Since I can't install anything on hosted agents, how am I supposed to have git lfs available?
EDIT
In this issue, I am not talking about git lfs authentication problems as described here. I am strictly talking about the issue of calling git lfs.
Once you are able to call git lfs, look at this answer to solve the authentication problem.
Git LFS is now supported by default on the Hosted Build Controller. But you do need to enable it in your get sources step.
You get this error message because git-lfs isn't installed on Hosted Build Agent by default.
And since you are using Hosted Build Agent, it would be a little troublesome to install git-lfs via Chocolatey on it as you don't have administrator permission. An alternative way would be download the binary files for git-lfs directly and upload it into Source Control. Then you can invoke the git-tfs.exe with an absolute path in your script.
Here are some more details around the solution provided by Eddie. git lfs is not a built-in command. It is a git custom command.
When you call git lfs, git.exe does not know about the lfs command. So it looks in the PATH environment variable and searches for a program named git-lfs.exe. Once found, it calls that program with the provided argument.
So calling git-lfs.exe pull is equivalent to calling git.exe lfs pull.
The solution suggested is therefore to download git-lfs.exe, add it your git repo (it should obviously not be tracked by LFS), and call git-lfs.exe.
It is also possible to add the folder that contains git-lfs.exe to your path environment variable. This makes it possible to use commands like git.exe lfs pull as you usually do.
If you are allowed to install software and have internet access during build you might be able to install git-lfs using the Chocolatey package in a cmd / PowerShell task prior to your git-lfs operation.

How Do I Update a Live Server Correctly Using Mercurial?

I'm new to Mercurial and version control, and although I'm only working on personal PHP application projects (until I hopefully get a job soon) I'm well overdue learning how it all works.
I've been reading about Mercurial all day, but I'm still confused on a few elements...
Firstly, I understand Mercurial CAN push my files straight to my live server, but I don't see many tutorials or examples explaining how this is done, so it leads me to think it's not used often? I currently use FTP to upload my files, and it's error prone to know which files have been modified, so I'd like to eliminate this obviously.
I also see services like BitBucket being mentioned a lot, but if I'm pushing to BitBucket how do I then get my files to my live server? Can I get only the changed files to upload via FTP, or do I need to install Mercurial on my server too or something?
Apologies if this is a basic question, I'm just a little lost as to how companies would/should use this service, and how files and uploads are handled elegantly. How should i go about version control on a personal project?
There are many ways to do that, but I'll try to narrow it down to the basic steps involved in a scenario using BitBucket:
1) Install Mercurial on both your dev machine and your live server.
2) Create a repository in BitBucket.
3) Clone the repository to your dev machine using the URL that appears in BitBucket, e.g.:
hg clone https://your_user#bitbucket.org/your_account/your_repos .
4) Clone the repository to your live server in the same way.
5) Do your dev and commit your code to the local repository on your dev machine (using hg commit). Then push the changesets to BitBucket using hg push.
6) Once you're ready to deploy the changes to your live server, log in to your live server and run hg pull -u.
I just use rsync to upload everything. If you're working by yourself, it's simple and works fine.
I set up an SSL certificate, and then made a bash shortcut ,p (target directory):
,p() { rsync -avz --delete ./ "user#server.com:/var/www/html/$#/"; }
Then, on my local host I can type ,p images and the current directory will be uploaded to mysite/images.
If you're always uploading to the same place, you can make a shortcut with no argument:
alias ,pm="rsync -avz --delete ./ "user#server.com:/var/www/html/";
Finally, if you just want to type the command:
rsync -avz --delete ./ "user#server.com:/var/www/html/

Gitzilla: Integration of github-project in Bugzilla

I am working on a Debian server, where I installed bugzilla. According to the suggestions in the gitzilla-installation guidelines, I would like to integrate Gitzilla to a project on github.com, using the github.com-project as my central repo. Therefore, I am not quite sure, where to do the following steps:
Switch to the hooks directory (/path/to/repository/.git/hooks) and delete the post-receive and update hooks.
Link (or copy) the gitzilla provided hooks:
ln -s $(which gitzilla-post-receive) post-receive
ln -s $(which gitzilla-update) update
Moreover, I tested to choose my github.com-URL to integrate in the /etc/gitzillarc, but without success. PyBugz is installed, and I defined the link to bugzilla, the user_name and PW of the bugzilla-admin.
Best,
H.M.
https://github.com/your_repository.git/.git/hooks will be the path where you should execute the steps.
In case you have a bare repository, then https://github.com/your_repository.git/hooks would be the path.

Jekyll not processing plugins on server

Jekyll is processing my _plugins folder fine on my local machine (OS X 10.7.4, ruby 1.9.3), but it's not processing them on the server (Ubuntu 12.04, ruby 1.9.3). Both have the same version of Jekyll installed (0.11.2).
I'm trying to use the generate_sitemap plugin, here.
I'm deploying via git and the post-receive hook, which looks like this:
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
I am seeing this error when I deploy:
remote: /home/ed/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
But, from what I've read, that's a Maruku warning and has nothing to do with the plugins.
Anybody have any ideas about what I can try to figure this out? I'm at a bit of a loss.
It's very hard to debug with Jekyll, but it's a great tool !!!
I assume you have more than one plugin in your _plugins folder.
So maybe one or some of your plugins , cause the problem.
If I'm right, you can do the following :
Kill your Jekyll
Create a backup of your plugins in another location (not in _plugins
folder).
Leave just one plugin in your _plugins folder and start Jekyll.
If it works , copy another plugin to the _plugins folder, until you
find the one which fails the Jekyll.
When you find it, you can add debug printouts to the problematic plugin (that's what I did).
Something like :
puts "before .... "
I have built the http://www.cloudifysource.org/ only with Jekyll and you can find and use lots of our useful examples in our GitHub repo : https://github.com/CloudifySource/cloudifysource.github.com
I had the same problem with Jekyll not loading plugins when called from the post-receive hook.
As is mentioned in the comments above, changing the current working directory to $TMP_GIT_CLONE does the trick.
You don't have to change anything in _config.yml.
#!/bin/bash -l
GIT_REPO=/my_repo.git
TMP_GIT_CLONE=/my_temp_folder/
PUBLIC_WWW=/my_public_folder/
git clone $GIT_REPO $TMP_GIT_CLONE
cd $TMP_GIT_CLONE # move to the temp dir
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
cd # move back to allow deletion
rm -Rf $TMP_GIT_CLONE
exit
This is a real head-scratcher seeing as executing the original post-receive hook manually as the git user works just fine... Anyway, Jekyll is now loading plugins on my server and hopefully making this a proper answer will help others to find this solution.
Lately, I start to build https://github.com/alswl/code-standards-jekyll with jekyll.
I write two plugins in _plugins, and I found it was hard to debug.
At first, I use puts "balabala" to debug, it seems work.But once I met problem that didn't generate anything in the _site folder, and there was no 'balabala' in the console, I was panic.
After I read the jekyll source, I try to set auto=false in _config.yml, running jekyll will produce some debug trace stack error. Thank godness.
So, ues auto=false will help you to debug plugins.