1

My Jekyll files are stored in Bitbucket, and I would like to be able to automatically generate the _site folder on every new change that gets pushed. (Note, I don't want to push my _site folder to Git, that is out of the question.)

Once this _site is generated, I would then like to automatically deploy it to my webserver via FTP.

Is this at all possible? What are my options?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jmak35
  • 13
  • 5
  • Note: you now (Oct. 2020) have the [option to use GitHub Actions](https://stackoverflow.com/a/64181253/6309). – VonC Oct 03 '20 at 06:09

1 Answers1

2

Since you didn't mention where the _site folder will go, here' a generic answer.

In short, you would need a webserver or a service that listens for a Bitbucket Post Commit Hook. Here is the relevant documentation for that.

That way, on every push, Bitbucket will trigger the action and notify your server/app/service that will then build the new _site and deploy to where you want to.

Here's a good tutorial on setting it up with the use of cron jobs and a webserver. Link.

A simple VPS would also work, or some tiny Amazon EC instance/Azure virtual machine.

Of course, these will likely not be 100% free.

If you hate using servers, a continuous integration (CI) service can be used instead, where on commit the hooks will trigger a build,

Travis-CI and Drone.io are free for public repositories, but if your repository is private you'll have to go for the paid service. There are many others as well.

(Note Travis-CI is not compatible with Bitbucket at the time of writing. It works with GitHub.)

Basically a CI is used to run tests, but aside from that, we can use it to generate a build and push or copy the _site to somewhere, maybe your own server. Or in the case of how this article describes it, another repository. (Read 'Becoming a Jekyll God' on some creative ways on deploying.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
matrixanomaly
  • 6,627
  • 2
  • 35
  • 58
  • Thanks for the great response matrixanomaly! The contents of my _site folder will go to my public_html folder on my webserver. My issue at the moment is that I don't have root access to the webserver because it's shared hosting, so I can't actually listen to the post commit hook there. My intent would be to use a separate VPS that would listen for the post commit hook, build the _site on the VPS and then FTP that to my webserver. Is the link you provide regarding cron jobs and flask still valid for this? – jmak35 Oct 23 '15 at 12:57
  • @jmak35 well I don't see why it won't work, as long as you can get the separate VPS that can listen for hooks build and do FTP to your webserver, it should work. However I've never done set ups like that so I can't guarantee anything, so your best bet is to try, and write a post about it :P Cron jobs and shell scripting might work too! (Edit: or you can move your jekyll source to github pages and use travis ci for the hook, a private one works too if you're willing to pay) – matrixanomaly Oct 23 '15 at 16:24
  • Here's a tutorial on the travis build route: http://ellismichael.com/technical/2015/06/12/using-travis-ci-with-github-pages/ – matrixanomaly Oct 23 '15 at 16:27
  • Thanks @matrixanomaly, I'm not much of an admin person, so I'm not really confident with setting up a VPS. But I'll give it a go. Once a Linux distro is installed, I just wouldn't know what else I'd need to install to make it operational... like security for example, and anything else that I may need. – jmak35 Oct 24 '15 at 04:24
  • @jmak35 I would recommend you go with the github pages, travis route, no need to deal with all that. – matrixanomaly Oct 24 '15 at 05:12
  • I actually want to use local hosting as it's a lot faster and my clients' customers are all local, so it just makes sense to host their websites on local servers, hence my choosing not to host with GitHub. Also BitBucket have free private repos, so it was a no brainer to go with them. Is it possible to have the Jekyll templates on GitHub, generated the _site with Travis CI but then instead of deploying to GitHub, is Travis CI capable of deploying to my webserver instead? – jmak35 Oct 24 '15 at 05:21
  • @jmak35 I have not tried but that should work, since Travis simply executes a script for testing, you just need to grant travis access to pushing files to your webserver. Maybe ask another question about travis ci and someone will help you out, as I am not too familiar with it. – matrixanomaly Oct 25 '15 at 02:55