Jekyll private deployment? - ruby

I have created jekyll site. Regarding the deployment I don't want to host on github pages. To host private domain I came know from documentation to copy the all files from _site folder. That's all wicked.
Question:
Each time I add new blog post, I am running cmd>jekyll build then I am copying newly created html to hosted domain. Is there any easy way to update without compiling each time ?
The reason, Why I am asking is because it will updated by non technical person
Thanks for the help!!

If you don't want to use GitHub Pages, AFAIK there's no other way than to compile your site each time you make a change.
But of course you can script/automate as much as possible.
That's what I do with my own blog as well. I'm hosting it on my own webspace instead of GitHub Pages, so I need to do these steps for each update:
Compile on local machine
Upload via FTP
I can do this with a single click (okay, a single double-click).
Note: I'm on Windows, so the following solution is for Windows.
But if you're using Linux/MacOS/whatever, of course you can use the tools given there to build something similar.
I'm using a batch file (the Windows equivalent to a shell script) to compile my site and then call WinSCP, a free command-line FTP client.
WinSCP allows me to store session configurations, so I saved the connection to my server there once.
Because of this, I didn't want to commit WinSCP to my (public) repository, so my script expects WinSCP in the parent folder.
The batch file looks like this:
call jekyll build
echo If the build succeeded, press RETURN to upload!
pause
set uploadpath=%~dp0\_site
%~dp0\..\winscp.com /script=build-upload.txt /xmllog=build-upload.log
pause
The first parameter in the WinSCP call (/script=build-upload.txt) specifies the script file which contains the actual WinSCP commands
This is in the script file:
option batch abort
option confirm off
open blog
synchronize remote -delete "%uploadpath%"
close
exit
Some explanations:
%~dp0 (in the batch file) is the folder where the current batch file is
The set uploadpath=... line (in the batch file) saves the complete path to the generated site into an environment variable
The open blog line (in the script file) opens a connection to the pre-saved session configuration (which I named blog)
The synchronize remote ... line (in the script file) uses the synchronize command to sync from the local folder (saved in %uploadpath%, the environment variable from step 2) to the server.
IMO this solution is suitable for non-technical persons as well.
If the technical person in your case doesn't know how to use source control, you could even script committing & pushing, too.

There are a number of options available which are mentioned in the documentation: http://jekyllrb.com/docs/deployment-methods/
If you are using Git, I would recommend the Git Post-Receive Hook approach. It simply builds the site after the new code is received:
GIT_REPO=$HOME/myrepo.git
TMP_GIT_CLONE=$HOME/tmp/myrepo
PUBLIC_WWW=/var/www/myrepo
git clone $GIT_REPO $TMP_GIT_CLONE
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
Since you mentioned that it will be updated by a non-technical person, you might try something like rack-jekyll to automatically rebuild when new files are FTP'd.

Related

Can lftp execute a command on the downloaded files (as part of the mirroring process)?

This may be asking too much from an already very powerful tool, but is there a chance that lftp mirror can execute a command during the mirroring process (from remote directory to the local machine)?
Specific example: lftp is asked to mirror a remote directory with xml files into a local folder and as soon as each file is downloaded/updated, it converts the file to JSON format using xml2json.
I can think of a solution that relies on monitoring the local copy of the mirrored folder for changes via find and then executing xml2json on the new/updated files, but perhaps there is a simpler way?
You can use xfer:verify and xfer:verify-command settings to run a local command on every transferred file.

Silent installation of git through use of .bat file on Windows

I am currently working on a Windows batch file that will allow me to silently install git (the executable for which will be placed in the folder that the .bat file will be running from) in a pre-specified location on the file system.
I've found this article which seems to provide some suitable advice:
https://github.com/msysgit/msysgit/wiki/Silent-or-Unattended-Installation
However, I'm not entirely sure what parameters I would need to mention in my LOADINF file. I would like to pre-define the options that the user would manually select throughout the various stages of installation, so that it can run through from start to finish without prompting anything from the user.
Can anyone help or point me to a place where I can find these parameters and their available values?
Create a file, for eg. my-config.cnf (or my-config.ini) with the following content:
[Setup]
Lang=default
Dir=C:\Program Files (x86)\Git
Group=Git
NoIcons=0
SetupType=default
...
<other options as shown in the msysgit wiki>
Now, in the batch file, when you execute the installation file (say msysgit-install.exe), use /LOADINF as follows:
msysgit-install.exe /SILENT /LOADINF="my-config.cnf"

Tortoise Bazaar commit password

I've recently set up a Bazaar repo on my FTP server (only access I have to back end, please don't go into reasons why I shouldn't use FTP).
I have managed to get everything working with short cuts such that I can include user and pass in the ftp URL:
ftp://"user":pass#host/path
Though I am trying to set up script that I can commit from a local directory with a batch file. The issue is I still require to put in the password everytime.
bzr commit "E:\Ryan - Backup\Other\test" -m batched
I had a crack at using the authentication.conf file but it either didn't work for me in this situation or I was doing it wrong. I placed the file in the .bzr folder so it was located at:
E:\Ryan - Backup\Other\Test\.bzr\authentication.conf
With the contents being:
# Identity on foo.net
[site]
scheme=ftp
host=site
user=username
password=pass
Am I doing something wrong or would I have to create a plugin to do what I am after.
P.S End result was to run a batch at startup and shut down so I could sync file updates between my computers.
UPDATE: I also tried the
guide that describes the location of:
C:\Users\rfleming\AppData\Roaming\bazaar\2.0
for the authetication.conf file, this didn't work either
UPDATE 2: Placing the authentication.conf into the:
C:\Users\rfleming\AppData\Roaming\bazaar\2.0
Worked fine and I just ended up using checkout and push for syncing and no manually password typing was required!

SVN Post Commit Hook Batch Windows

I have a Windows Server running Visual SVN Server to store our repositories.
Also on that server is our test copy.
I'm trying to set up a simple SVN post-commit hook so it updates that test copy automatically every time I commit something
In Visual SVN in the post-commit hooks I've set up like this
"C:\Program Files (x86)\VisualSVN Server\bin\updatescripts.bat" D:\inetpub\TESTCOPY
Then that batch file has a simple update like this
PATH=%PATH%;"C:\Program Files (x86)\VisualSVN Server\bin\"
svn update %1
If I run the batch file in the server by double clicking on it or from command line works fine.
When committing something from my laptop it freezes and doesn't give me any error and locks the test copy so then I need to go in and run a clean up.
Visual SVN service is running as network service and this aacount has full access to the bin folder and the test copy on the server.
Any idea how to set up a simple svn update post commit hook anyone?
Thanks
Fede
I had a similar problem and it turned out to be that SVN likes paths to use forward slashes instead of backslashes.
Try this:
set MYPATH=%1
:: Transform backslashes to forward slashes
set MYPATH=%MYPATH:^\=/%
svn update %MYPATH%
You're running the svn update command. Exactly what working copy are you trying to update?
The parameter being passed is the Repository's path. This points not to a working directory, but to the directory that contains the Subversion master repository. This is the same directory where your post commit hook is stored.
Subversion hooks do not have access to the user's working directory, so you can't manipulate the user's files. Hook scripts usually should be using svnlook and not svn. By doing this, you prevent yourself from getting into any sort of trouble.
It is possible to update a Subversion working copy on the server, if you know the location:
PATH=%PATH%;"C:\Program Files (x86)\VisualSVN Server\bin\"
set SVN_WORK_DIR=C:\SVN\workdir"
svn update %SVN_WORK_DIR%
However, I wouldn't recommend this because it ties up Subversion. The user who did the commit would have to wait until the update is complete before Subversion returns the control of the prompt back to the user.
After trying a million different things this worked for me...
I put this in my post-commit hook
"C:\Program Files\VisualSVN Server\bin\svn.exe" update "C:\my path\"
where my path is the path to the working copy to be updated
Also I had to change the service to run as local system
That is really not the way you want to do that. What you should do is use something like Jenkins to watch your repository. Jenkins can watch your repository, and it when it changes, update your test copy, kick-off builds, run automated tests, etc.

Git - post-receive hook not working on remote windows server

I'm trying to get a git post-receive hook working on Windows.
I'm using Git 1.7.9 (Msysgit) and have a repo locally and a bare repo on a remote server. I can fetch, commit, push etc. I've set up a post-receive hook that should checkout the files into a working folder (part of the deployment process) but it doesn't seem to work.
Here's what I do:
Change a file, stage and commit it
Push to remote server - successfully
Expect to see the echo - don't see the echo
Check working folder on server - latest files are not there
Log onto the server and run the hook script manually - latest files are checkout out into the working folder.
I changed the hook so it does nothing except echo a message and I've read that I should see this in my console after pushing. But this is not being displayed so I can only assume the hook is not being fired off.
I'm pushing over HTTP with git dot aspx on the server handling the request and pusing via the gui locally. After that failed I tried Bonobo and the hook doesn't work when pushing via the gui or a bash console.
I'm assuming someone has this working somewhere but after two days of searching all I have found are solutions that don't help or people with the same problem that has gone unanswered.
(I'm a git newbie btw).
Cheers.
Update
I'm starting to think it may be to do with permissions - but Unix permissions, rather than NTFS. When #eis mentioned permissions I had assumed NTFS. But after more digging it seems that Git on Windows still checks for Unix file perms.
So I suspect the issue is that the post-receive file is not executable as when I do a ls -o it's -rw-r--r-- (644 I believe). If I try and change this through bash and chmod 777 post-receive then do ls -o the permissions are the same.
The strange this is that as soon as I edited post-receive (with notepad++) the execute bit gets removed. (my test script that ends in .bat does retain its execute bits though...)
BTW, the user I'm logged on as is the owner of the files (according to ls -o) and yet I can't set the permissions.
Starting to get really confused now. Am I missing something really obvious?
Update 2
Neither chmod 777 post-receive nor chmod a+x post-receive work. I took a new, clean post-receive file, uploaded it the to the server and checked the permissions and it had execute. If I rename the file (to remove sample) in Windows then execute is removed. If I do it in bash with mv execute is retained.
But, whenever I edit the file (in Windows or in bash with vi) then execute gets removed.
So, the problem now is why does it remove the execute bits when I edit the file?
Hopefully this is the final hurdle and the cause of it not executing...
You are going to have to patch git to make this work. The checks in builtin/receive-pack.c are for access(path, X_OK). In msysgit this diverts to mingw_access which throws away the X_OK bit as it is simple not supported on Windows.
On windows, we have no flag to specify a file is executable. Systems often do some emulation of this. For instance, tcl will look for any extension in the PATHEXT environment variable to decide that a file is executable. We can't do that here as the hook names are hardcoded without any extensions.
Instead, I suggest changing the access test to just check the file exists and then call execv on the path. The mingw version of this (in compat/mingw.c) looks for script files and will read the shbang line and launch an appropriate interpreter (sh, perl etc). So modifying builtin/receive-pack.c:run_update_hook should let this work for you. Currently the hook running uses start_command and I think that should call down to execv for you.
In short, change the access test and it will probably work.
When using msysgit on the server and pushing via a file share hooks work without problem now. Maybe this was fixed in mysysgit since the answer was written. I didn't look into it.
I also noticed that the original question stated git dot aspx and Bonobo were being used which use GitSharp.dll. This would mean the application is not shelling out to the git.exe and hooks would not be handled the same way.
For example, the GitSharp.dll used in git dot aspx has it's own hook post-receive hook implementation which could be performed in C#:
public void Receive(Stream inputStream, Stream outputStream)
{
using (var repository = GetRepository())
{
var pack = new ReceivePack(repository);
pack.setBiDirectionalPipe(false);
//setup post receive hook here
pack.setPostReceiveHook(new PostRecieveHook());
pack.receive(inputStream, outputStream, outputStream);
}
}
public class PostRecieveHook : IPostReceiveHook
{
public void OnPostReceive(ReceivePack rp, ICollection<ReceiveCommand> commands)
{
//Do PostRecieve Hook Work Here
}
}
I hope to help others with confusion between libraries that are implementations of Git and applications that call out to the actual git.exe.

Resources